[issue41389] Garbage Collector Ignoring Some (Not All) Circular References of Identical Type

Tim Peters report at bugs.python.org
Fri Jul 24 17:13:11 EDT 2020


Tim Peters <tim at python.org> added the comment:

What makes you think that? Your own output shows that the number of "Active" objects does NOT monotonically increase across output lines. It goes up sometimes, and down sometimes.  Whether it goes up or down is entirely due to accidents of when your monitoring thread happens to wake up during the lifetime of the program's gc history.

I boosted the loop count to 10 million on my box just now. It had no significant effect on peak memory use. At the end:

>>> A.COUNT, A.TOTAL, B.COUNT, B.TOTAL
(298, 10000000, 298, 10000000)
>>> gc.collect()
1188
>>> A.COUNT, A.TOTAL, B.COUNT, B.TOTAL
(1, 10000000, 1, 10000000)

There is no leak. An A and B object survive collect() because the last A object created remains bound to the variable `a` used in the loop (so is still reachable).

So I thank you for creating a nice test program, but I'm closing this since it doesn't demonstrate a real problem.

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list