[docs] [issue33814] exec() maybe has a memory leak

Steven D'Aprano report at bugs.python.org
Sat Jun 9 20:25:05 EDT 2018


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I decided to risk this "catastrophic" leak, and ran this:

py> x = leaks()
py> x
((2, 3), <weakref at 0xb7a1998c; to 'function' at 0xb789826c (f)>, 24)
py> import gc
py> gc.collect()
22
py> x
((2, 3), <weakref at 0xb7a1998c; dead>, 24)


so I think Eric is correct, it is just a garbage collection issue. Possibly a bug, possibly normal behaviour. I don't think it is a documentation bug, if it is a bug at all it might be a garbage collection bug.

But I really don't know, because I don't understand what Dan thinks is the memory leak here or why it happens. I *think* Dan might be referring to the fact that each time you call leaks(), there's one extra reference to itertools.repeat.

Dan, if you can confirm that's the leak you are referring to, we would have a better chance of deciding whether it is a bug and if so if it is specific to exec.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33814>
_______________________________________


More information about the docs mailing list