Where'd my memory go? (was Re: [Python-Dev] Dictionary sparseness) (original) (raw)

M.-A. Lemburg mal@lemburg.com
Tue, 06 May 2003 18:12:32 +0200


Tim Peters wrote:

[M.-A. Lemburg]

If someone really care, I suppose that the garbage collector could do an occasional scan of the int free list and chop of the tail after a certain number of entries. Int objects aren't allocated individually; malloc() is used to get single "int blocks", which contain room for about 1000 ints at a time, and these blocks are carved up internally by intobject.c. So it isn't possible to reclaim the space for a single int, so "tail" doesn't mean anything useful in this context.

Hmm, looking at the code it seems that the different blocks are not referencing each other. Wouldn't it be possible to link them together as list of blocks ? This list could then be used for the review operation.

FWIW, Unicode free lists have a cap to limit the number of entries in the list to 1024. The Unicode freelist is more like the frameobject freelist that way (it is possible to reclaim the space for an individual Unicode string or frame object).

Probably :-)

Would using the block technique from the int implementation make a difference for the frame objects ? I would guess that a typical Python program rarely has more than 100 frames alive at any one time. These could be placed into such a block to make setting them up faster, possible making Python function calls a tad snippier.

-- Marc-Andre Lemburg eGenix.com

Professional Python Software directly from the Source (#1, May 06 2003)

Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/


EuroPython 2003, Charleroi, Belgium: 49 days left