This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: GC memory leak using weak and cyclic references
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: koehlma
Priority: normal Keywords:

Created on 2016-01-24 10:42 by koehlma, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gc_test_code.py koehlma, 2016-01-24 10:42 example code
Messages (1)
msg258886 - (view) Author: Maximilian Köhl (koehlma) Date: 2016-01-24 10:42
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
[...]
History
Date User Action Args
2022-04-11 14:58:26adminsetgithub: 70378
2016-01-24 11:14:20koehlmasetstatus: open -> closed
resolution: not a bug
2016-01-24 10:42:56koehlmacreate