【问题标题】:MemoryError when using imaplib fetch使用 imaplib 获取时的 MemoryError
【发布时间】:2010-07-12 11:12:28
【问题描述】:

请帮助我,我在尝试获取特定电子邮件时遇到 MemoryError。这是错误信息:

python(23838,0x1888c00) malloc: *** vm_allocate(size=3309568) failed (error code=3)
python(23838,0x1888c00) malloc: *** error: can't allocate region
python(23838,0x1888c00) malloc: *** set a breakpoint in szone_error to debug
Exception in thread Thread-1:Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/threading.py", line 442, in __bootstrap
    self.run()
  File "/Volumes/SvnDevDisk/branches/HaversackProject_Version_0.2/plugins/GaMailClientPlugin/python/imap/imap_reader.py", line 25, in run
    self.readMailbox(eachMailbox)
  File "/Volumes/SvnDevDisk/branches/HaversackProject_Version_0.2/plugins/GaMailClientPlugin/python/imap/imap_reader.py", line 58, in readMailbox
    resp, content = _mailConnection.fetch(num, '(RFC822 FLAGS)')
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 417, in fetch
    typ, dat = self._simple_command(name, message_set, message_parts)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 1004, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 830, in _command_complete
    typ, data = self._get_tagged_response(tag)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 935, in _get_tagged_response
    self._get_response()
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 896, in _get_response
    data = self.read(size)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/imaplib.py", line 231, in read
    return self.file.read(size)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/socket.py", line 301, in read
    data = self._sock.recv(recv_size)
MemoryError

这是我的代码:

resp, content = _mailConnection.fetch(num, '(RFC822 FLAGS)')

我正在使用 python 2.3.5

提前致谢!

【问题讨论】:

    标签: python malloc imaplib


    【解决方案1】:

    MemoryError 通常表示您的系统已用完可用内存。也许您的 Python 脚本保留了对它看到的所有消息的引用,并且它们的总和太大而无法放入内存?

    【讨论】:

    • 我已经尝试获取耗尽内存的特定消息,它的大小几乎是 5MB。我对python相当陌生,关于如何有效地获取大消息的任何建议,尤其是那些带有大附件的消息。谢谢!
    【解决方案2】:

    http://bugs.python.org/issue1092502

    a_lauer 建议的修复方法似乎解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2019-09-15
      • 2011-04-16
      • 2018-03-09
      • 2015-04-29
      • 1970-01-01
      • 2015-04-17
      • 2014-10-03
      • 2019-10-10
      • 1970-01-01
      相关资源
      最近更新 更多