[Python-Dev] Problems with the Python Memory Manager

Michael Hudson mwh at python.net
Thu Nov 17 10:42:23 CET 2005

Travis Oliphant <oliphant at ee.byu.edu> writes:

> Bingo.  Yes, definitely allocating new _types_ (an awful lot of them...) 
> --- that's what the "array scalars" are: new types created in C.

Ah!  And, er, why?

> If they don't get properly collected then that would definitely have
> created the problem.

types do get collected -- but only after the cycle collector has run.
If you can still reproduce the problem can you try again but calling

> It would seem this should be advertised when telling people to use
> PyObject_New for allocating new memory for an object.

Nevertheless, I think it would be good if pymalloc freed its arenas.
I think the reasons it doesn't are because of worries that people
might be called PyObject_Free without holding the GIL, but that's been
verboten for several years now so we can probably just let them

I think there's even a patch on SF to do this...


  The use of COBOL cripples the mind; its teaching should, therefore,
  be regarded as a criminal offence.
           -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5

More information about the Python-Dev mailing list