[Python-Dev] refleaks and caches

Christian Heimes lists at cheimes.de
Mon Jan 28 13:54:32 CET 2008


Jeroen Ruigrok van der Werven wrote:
> -On [20080128 03:13], Christian Heimes (lists at cheimes.de) wrote:
>> Do the int/float free lists cause any trouble or can they eat lots of
>> memory?
> 
> I hope I am interpreting it correctly, but it seems
> http://evanjones.ca/memoryallocator/ explanation on that still applies:

[snip]

Yes, the explanation still applies. It took me a while to understand how
the free lists are working. Some genius came up with the idea to (ab)use
the op_type field of the PyObject struct to link the freed objects. All
the time I wondered why it assigns something complete different than a
type object to the type field.

In patch http://bugs.python.org/issue1953 I've moved the compact code
from the PyFloat/Int_Fini functions to two new functions and exposed
them as a single Python function gc.compact_freelists(). It doesn't
solve the problem described in the text but at least it gives a user the
chance to free some memory manually.

Christian


More information about the Python-Dev mailing list