有足够的可用内存,但在Python中退出“MemoryError”

时间:2015-07-16 13:56:33

标签: python numpy out-of-memory

我的电脑是Win7的64位操作系统。 RAM为16GB。我想将1 GB csv数据加载到numpy.array中。我监视资源,发现程序在内存达到8.56GB时退出。

我的Python版本是:win32上的Python 2.7.10(默认,2015年5月23日,09:44:00)[MSC v.1500 64位(AMD64)]

守则:

QA_file=open("QA_URLs.csv")
urlreader=csv.reader(QA_file, delimiter=',', quotechar='"')

QA_HrefId=[]
QA_PostId=[]
QA_PostTypeId=[]
QA_OwnerUserId=[]
QA_ParentId=[]
QA_Href=[]
QA_CreationDate=[]

for line in urlreader:
    if len(line)==7:
        QA_HrefId.append(line[0])
        QA_PostId.append(line[1])
        QA_PostTypeId.append(line[2])
        QA_OwnerUserId.append(line[3])
        QA_ParentId.append(line[4])
        QA_Href.append(line[5])
        QA_CreationDate.append(line[6])


np_QA_HrefId=np.array(QA_HrefId)
np_QA_PostId=np.array(QA_PostId)
np_QA_PostTypeId=np.array(QA_PostTypeId)
np_QA_OwnerUserId=np.array(QA_OwnerUserId)
np_QA_ParentId=np.array(QA_ParentId)
np_QA_Href=np.array(QA_Href)
np_QA_CreationDate=np.array(QA_CreationDate)

例外情况:

Traceback (most recent call last):
  File "D:Recommender.py", line 81, in <module>
    np_QA_Href=np.array(QA_Href)
MemoryError

为什么在有足够的可用内存时会报告“MemoryError”?

0 个答案:

没有答案