Memory Leakage with Tuples and Lists

Robin Becker robin at jessikat.fsnet.co.uk
Sat Jan 6 09:54:56 EST 2001


In article <936vkc$ol1$1 at news.nuri.net>, June Kim <junaftnoon at nospamplzy
ahoo.com> writes
....
>Well, to make it simple, when I do:
>
>temp1=range(800000)
>
>it seems like I'm losing about 13MB immediately, whereas
>
>temp2='a'*800000 consumes almost exactly 8MB.
>
>When I "del temp1", it frees about 3.2MB which is, I suppose, right size for
>800000s integers, and "del temp2" frees up exactly the same that it took up
>in the first place. 10MB's more overhead in temp1 seems too much, and why
>not returned wholly on the deletion?
>
>ps. I checked the memory status with System Monitor, not running any other
>programs besides Python.
>
....
well I see around 8Mb lost for 
temp1=range(1000000)
but some is regained when I delete temp. I guess that's 4Mb for the ints
and 4Mb for the list of pointers. I guess that M$ has an allocator that
can recover memory (perhaps at the end of the heap). I don't keep losing
memory if I repeat the assign and del operation so I claim that's not a
leak.

The other case will allocate smaller amounts of memory as it's
essentially just 1byte + the pointers. I'm not sure why you see 8Mb not
3.2Mb
-- 
Robin Becker



More information about the Python-list mailing list