内存错误,python
我在处理一个大小为1.45GB的.xml文件时遇到了内存错误。为了排查问题,我尝试在一个更小的文件上运行代码,结果没有问题,所以代码里应该没有错误。这个代码的功能是打开一个xml文件,进行一些操作,然后把结果保存到一个新的txt文件里。我使用的是Windows 7 32位系统,内存是2GB,运行的是Python 2.6。
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
openfile('ukwiki-latest-pages-articles.xml')
File "C:\Users\Vof Freeman\Desktop\Python\test.py", line 7, in openfile
contents = F.read()
File "C:\Python26\lib\codecs.py", line 666, in read
return self.reader.read(size)
File "C:\Python26\lib\codecs.py", line 466, in read
newdata = self.stream.read()
MemoryError