memory recycling/garbage collecting problem
Yuanxin Xi
xi11west at gmail.com
Tue Feb 17 00:21:16 EST 2009
I'm having some problems with the memory recycling/garbage collecting
of the following testing code:
>>> a=[str(i) for i in xrange(10000000)]
This takes 635m/552m/2044 memory (VIRT/RES/SHR)
>>> b={}
>>> for i in xrange(10000000):
... b[str(i)]=i
Then the memory usage increased to 1726m/1.6g/2048
>>> del b
I expect the memory usage drop to the ammount before b was
created(635m/552m/2044), but it's actually 1341m/1.2g/2048
Could anyone please explain why this happens? It seems some memory
are not freed. I'm running into problems with this as my program is
very memory cosuming and need to frequently free some object to reuse
the memory. What is the best way to free the memory of b completely
(i.e. back to the status as b was created)? I'm using Python 2.5.2
Thanks.
Yuanxin
More information about the Python-list
mailing list