[issue26190] GC memory leak using weak and cyclic references

Maximilian Köhl report at bugs.python.org
Sun Jan 24 05:42:56 EST 2016


New submission from Maximilian Köhl:

In the attached code the object initially bind to `a` is never garbage collected although there are no references left. The finalizer of `b` is executed and the weak reference to it becomes dead however the garbage collector does not free the object itself and it could be resurrected with `gc.get_objects()`.

Output:
gc: collecting generation 2...
gc: objects in each generation: 27 0 5795
gc: collectable <B 0x7f158796a320>
gc: collectable <dict 0x7f15879e3088>
finalize: b <__main__.A object at 0x7f158796acc0>
gc: done, 3 unreachable, 0 uncollectable, 0.0005s elapsed
gc: collecting generation 2...
gc: objects in each generation: 1 0 5812
gc: done, 0.0005s elapsed
gc: collecting generation 2...
gc: objects in each generation: 1 0 5812
gc: done, 0.0005s elapsed
[...]

----------
components: Interpreter Core
files: gc_test_code.py
messages: 258886
nosy: koehlma
priority: normal
severity: normal
status: open
title: GC memory leak using weak and cyclic references
type: resource usage
versions: Python 3.5
Added file: http://bugs.python.org/file41704/gc_test_code.py

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


More information about the Python-bugs-list mailing list