memory recycling/garbage collecting problem

Chris Rebert clp2 at rebertia.com
Tue Feb 17 09:40:29 CET 2009


On Tue, Feb 17, 2009 at 12:33 AM, Aaron Brady <castironpi at gmail.com> wrote:
> On Feb 16, 11:21 pm, Yuanxin Xi <xi11w... at gmail.com> wrote:
>> 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
> snip
>
> 'gc.collect()' -- I believe, but I'm not the specialist in it.

If I understand correctly, that only effects objects that are part of
a reference cycle and doesn't necessarily force the freed memory to be
released to the OS.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list