Freeing memory from Python lists!

Tim Peters at
Wed Jul 11 16:18:31 EDT 2001

[Chris Spencer, on Win2k "losing" memory after
    result = []
    for count in xrange(510*478):
    del result

> I can confirm these results.  Why would a deleted list
> retain 90% of its memory usage after being deleted?  Sounds like
> a pointer is getting lost somewhere.

Nothing is lost.  All flavors of Windows have flaky (yet different) malloc()
implementations that work especially poorly with append-one-at-a-time list
behavior.  If you try it under the current CVS Python, it should work better
on (all flavors of) Windows.  In the meantime, Windows malloc has chewed up
some *address space* (virtual memory) due its own internal fragmentation,
which is not necessarily the same thing as "memory" (RAM).  Getting an
accurate view of Windows memory use can't be done from Task Manager; you
have to walk the heap structures and analyze them yourself.

More information about the Python-list mailing list