[issue29671] Add function to gc module to check if any reference cycles have been reclaimed.

Mark Dickinson report at bugs.python.org
Mon Feb 27 15:44:57 EST 2017


Mark Dickinson added the comment:

If I understand correctly, you can already achieve what you want by:

1. Disabling gc (with gc.disable()) at the beginning of your code, and possibly adding a `gc.collect()` immediately afterwards for good measure.
2. Doing a gc.collect() (and taking note of the return value) at the end of your code.
3. To be on the safe side, also check whether there's anything in `gc.garbage`.

If no reference cycles were created, `gc.collect()` will return `0`, and `gc.garbage` will be empty.

----------
nosy: +mark.dickinson

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


More information about the Python-bugs-list mailing list