Memory Leakage with Tuples and Lists

June Kim junaftnoon at nospamplzyahoo.com
Sat Jan 6 06:28:57 EST 2001


"Robin Becker" <robin at jessikat.fsnet.co.uk> wrote in message
news:x7ldJVA2kvV6EwMC at jessikat.fsnet.co.uk...
> In article <936h6e$d11$1 at news.nuri.net>, June Kim <junaftnoon at nospamplzy
> ahoo.com> writes
> >Tested under Python 1.5 and 2.0 on Win32:
> >
> >1.
> >Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)
> >Type "copyright", "credits" or "license" for more informat
> >>>> for j in range(10):
> >...     temp=range(800000)
> >...     del temp
> >
> >2.
> >Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)
> >Type "copyright", "credits" or "license" for more informat
> >>>> for j in range(10):
> >...     temp='a'*8000000
> >...     del temp
> >
> >In the case of #2, there is no memory leakage at all. All the memory is
> >returned 100%. However, in #1, there is a severe memory leakage, a few
mega
> >bytes. Do you guys experience this on *nices as well?
> >
> >
> I don't see the leak you describe; how did you check for it? Certainly
> the total memory used grows the first time I use the code; after all
> 800000 ints is 3.2M; if there a serious leak I would expect to see
> around 32M disappear each time I run the code. I certainly don't see
> that.
> --
> Robin Becker

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.

Best regards,

June




More information about the Python-list mailing list