使用imaplib fetch时出现MemoryError

1 投票
2 回答
560 浏览
提问于 2025-04-16 00:52

请帮帮我,我在尝试获取一封特定的邮件时遇到了内存错误。这个是错误信息:

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

提前谢谢你们!

2 个回答

0

在这里,有个链接可以查看相关问题:http://bugs.python.org/issue1092502

那位叫 a_lauer 的用户提的解决办法,似乎解决了我的问题。

0

内存错误通常意味着你的系统没有足够的可用内存了。可能是你的Python脚本保存了所有它处理过的消息的引用,而这些消息的总和太大,无法放进内存里?

撰写回答