[Spambayes] Problem with imap filter on mac os x: memory error

Perry Greenfield perry at stsci.edu
Thu Jul 22 16:18:35 CEST 2004

On 7/21/04 8:35 PM, "Tony Meyer" <tameyer at ihug.co.nz> wrote:

>> But when I try to run it as a filter, even by making the inbox
>> much smaller (just a few hundred messages), I keep getting a memory
>> allocation error. Any ideas on what is going wrong? No other
>> mail programs are running at the time.
>> It's a Mac G5 running OS X 10.3
>> % python sb_imapfilter.py -t -c -l 5 -P
>> SpamBayes IMAP Filter Version 0.4 (May 2004)
>> and engine SpamBayes Engine Version 0.3 (January 2004).
>> Password: 
>> *** malloc: vm_allocate(size=4890624) failed (error code=3)
>> *** malloc[4452]: error: Can't allocate region
> [...]
>> MemoryError
> I really don't like the look of those malloc errors.  It appears that it's
> only asking for 4.89 MB of memory, which is not a lot really.  Googling for
> this error code gives examples of people with the problem, but they're
> typically asking for more than a GB of memory (at which point the error is
> more understandable).
> Is there plenty of free space on the drive that's being used for the swap?
> Do any other programs have memory troubles?
Yes, no.

> Is there a fairly large message in the IMAP folders that it's scanning
> through?  (perhaps something about 4.9 MB?)  Python's imaplib tries to
> receive the whole message in one chunk, meaning (I presume) that the memory
> is requested in one chunk, but if that's a problem then it's a Python
> problem and I would have thought that some other OX X 10.3 Python user would
> have hit it.  (The google results did have a few Perl hits, though).
I think you put your finger on the problem. I did happen to send myself some
large mail message recently, just about that size. When I deleted them, the
problem disappeared.

> Could you try this and see what happens?
> % python
>>>> import imaplib
>>>> i = imaplib.IMAP4("my.mail.server")
>>>> i.login("username", "password")
>>>> i.select()
>>>> i.fetch(1)
>>>> i.logout()
>>>> (control-z)
I tried this after deleting the mail messages ( I can undelete them if
necessary) but this is what happened:

[GCC 3.3 20030304 (Apple Computer, Inc. build 1640)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import imaplib
('OK', ['User logged in'])
>>> i.select()
('OK', ['842'])
>>> i.fetch(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: fetch() takes exactly 3 arguments (2 given)

So is the fetch call wrong?

Thanks for pointing in the right direction.


More information about the Spambayes mailing list