Python IMAP4 Memory Error

Fredrik Lundh fredrik at pythonware.com
Fri Dec 23 04:29:15 EST 2005


Jean-Paul Calderone wrote:

> >On a second trial, it's also failed on Python 2.3.5 for Windows, Python
> >2.3.3 for Windows, and Python 2.2.3 for Windows. So this seems to me as
> >a Windows system related bug, not a particular version of Python bug.
>
> Arguably, it's a bug in Python's imaplib module.  Sure, the Windows memory
> allocator is feeble and falls over when asked to do perfectly reasonable things.

if you look at the debug output (which you may already have done),
it's an obvious case of fragmentation-inducing behaviour.  any malloc-
based system may choke on the sequence

    for a large number of attempts:
        allocate a 15 megabyte block
        shrink block to a couple of kilobytes
        occasionally allocate a medium-sized block

from what I can tell, replacing the

            data = self.sslobj.read(size-read)

line with

            data = self.sslobj.read(min(size-read, 16384))

should do the trick.

</F>






More information about the Python-list mailing list