malloc (error code=12)

Roger Binns rogerb at rogerbinns.com
Wed Jan 21 22:01:27 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arash Arfaee wrote:
> Python(15492,0xb0103000) malloc: *** mmap(size=393216) failed (error
> code=12)

errno 12 is ENOMEM on Macs (and Linux for that matter).  You may have
run out of swap space, but that is unlikely.

The most likely cause is that you have run out of address space.  For
example a 32 bit process has 4GB of address space available.  The kernel
will take up to 2GB of that depending on the operating system.  Various
shared libraries and your program will take some.  The program stack
space will take some more.

In your case malloc is attempting to allocate 384kb of memory using mmap
by mapping anonymous memory (swap) into the address space.  (The
advantage of doing it this way is that the space can be unmapped when no
longer needed.)

With no appropriate address space left for this chunk, you get the
error.  You are either trying to use too much stuff or there is a memory
leak.  Calling gc.collect() can result in some deferred items being freed.

To get an idea of how address space works, check out this article about
what Linux did in 2004.  The same principles apply to MacOSX.  You can
also see how the theoretical 4GB quickly disappears!

  http://lwn.net/Articles/91829/

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkl34YMACgkQmOOfHg372QRG9ACeKitN3f7cAcN1AOf76yTa9w+q
CywAoL8JJ2/VvNe8eHOfP1r9UhOJH59z
=EUjX
-----END PGP SIGNATURE-----




More information about the Python-list mailing list