为什么带有列表`append()`的Python`Memory Error`剩余大量RAM [英] Why Python `Memory Error` with list `append()` lots of RAM left
问题描述
我正在从一组文本文件构建大型数据字典.当我阅读并处理这些行时,我append(dataline)
进入了列表.
I am building a large data dictionary from a set of text files. As I read in the lines and process them, I append(dataline)
to a list.
在某些时候,append()
会生成一个Memory Error
异常.但是,看着崩溃时在Windows任务管理器中运行的程序,我看到有4.3 GB的可用空间和1.1 GB的可用空间.
At some point the append()
generates a Memory Error
exception. However, watching the program run in the Windows Task Manager, at the point of the crash I see 4.3 GB available and 1.1 GB free.
因此,我不明白发生此异常的原因.
Thus, I do not understand the reason for the exception.
Python版本为2.6.6.我猜,唯一的原因是它无法使用更多的可用RAM.如果是这样,是否可以增加分配?
Python version is 2.6.6. I guess, the only reason is that it is not able to use more of the available RAM. If this is so, is it possible to increase the allocation?
推荐答案
如果您使用的是32位版本的Python,则可能要尝试使用64位版本.
If you're using a 32-bit build of Python, you might want to try a 64-bit version.
一个进程可以使用32位地址来寻址最多4GB的RAM,但是通常情况下(取决于操作系统),获取的空间会少得多.听起来您的Python进程可能已达到此极限. 64位寻址消除了此限制.
It is possible for a process to address at most 4GB of RAM using 32-bit addresses, but typically (depending on the OS), one gets much less. It sounds like your Python process may be hitting this limit. 64-bit addressing removes this limitation.
edit Since you're asking about Windows, the following page is of relevance: Memory Limits for Windows Releases. As you can see, the limit per 32-bit process is 2, 3 or 4GB depending on the OS version and configuration.
这篇关于为什么带有列表`append()`的Python`Memory Error`剩余大量RAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!