[Python-Dev] When do sets shrink?

"Martin v. Löwis" martin at v.loewis.de
Thu Dec 29 01:03:51 CET 2005


Noam Raphael wrote:
> I checked - when doing the same thing with lists, all the memory was
> released for use by other Python objects, and most of it was released
> for use by the operating system.

In this specific case, perhaps. malloc will typically return memory to
the system only if that memory is at the end of the heap. If there
is more memory after block to be released, it can't return the memory
block, because it won't punch a whole into the heap.

So as soon as you have more than one object, things become interesting.

Different systems use different, enhance strategies, of course. For
example, Linux glibc malloc will allocate "large" blocks through
mmap (instead of sbrk), such blocks then can be returned individually.

Regards,
Martin


More information about the Python-Dev mailing list