memory recycling/garbage collecting problem

David Niergarth jdnier at
Thu Feb 26 10:00:34 EST 2009

Tim Peters showed a way to demonstrate the fix in

> For simpler fun, run this silly little program, and look at memory
> consumption at the prompts:
> """
> x = []
> for i in xrange(1000000):
>    x.append([])
> raw_input("full ")
> del x[:]
> raw_input("empty ")
> """
> For example, in a release build on WinXP, VM size is about 48MB at the
> "full" prompt, and drops to 3MB at the "empty" prompt.  In the trunk
> (without this patch), VM size falls relatively little from what it is
> at the "full" prompt (the contiguous vector holding a million
> PyObject* pointers is freed, but the obmalloc arenas holding a
> million+1 list objects are never freed).
> For more info about the patch, see Evan's slides from _last_ year's PyCon:

I'm not sure what deleting a slice accomplishes (del x[:]); the
behavior is the same whether I do del x or del x[:]. Any ideas?


More information about the Python-list mailing list