memory recycling/garbage collecting problem

Floris Bruynooghe floris.bruynooghe at gmail.com
Tue Feb 17 15:30:45 CET 2009


On Feb 17, 5:31 am, Chris Rebert <c... at rebertia.com> wrote:
> My understanding is that for efficiency purposes Python hangs on to
> the extra memory even after the object has been GC-ed and doesn't give
> it back to the OS right away.

Even if Python would free() the space no more used by it's own memory
allocator (PyMem_Malloc(), PyMem_Free() & Co) the OS usually doesn't
return this space to the global free memory pool but instead leaves it
assigned to the process, again for performance reasons.  Only when the
OS is running out of memory it will go and get the free()ed memory of
processes back.  There might be a way to force your OS to do so
earlier manually if you really want but I'm not sure how you'd do
that.

Regards
Floris



More information about the Python-list mailing list