[issue12075] python3.2 memory leak when setting integer key in dictionary

Ezio Melotti report at bugs.python.org
Sat May 14 09:55:55 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

I think this has to do with class attributes and reload():

wolf at hp:~/dev/py/py3k$ cat leak.py
class Foo: pass
Foo.l = list(range(65535))

wolf at hp:~/dev/py/py3k$ ./python 
Python 3.3a0 (default:4b122cac7ac5+, May 14 2011, 10:01:13) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import imp, leak; imp.reload(leak)
<module 'leak' from 'leak.py'>
[189091 refs]
>>> imp.reload(leak)
<module 'leak' from 'leak.py'>
[254649 refs]
>>> imp.reload(leak)
<module 'leak' from 'leak.py'>
[320207 refs]
>>> imp.reload(leak)
<module 'leak' from 'leak.py'>
[385765 refs]
>>> import gc; gc.collect()
28
[123927 refs]

However calling gc.collect() explicitly seems to fix the problem.

----------
nosy: +ezio.melotti
versions: +Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12075>
_______________________________________


More information about the Python-bugs-list mailing list