Last active
January 24, 2016 10:59
-
-
Save koehlma/965eab2bb8ac7f2d6a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gc: collecting generation 2... | |
gc: objects in each generation: 13 0 5824 | |
gc: collectable <B 0x7f8c86b4ec50> | |
gc: collectable <dict 0x7f8c86b57248> | |
finalize b <__main__.A object at 0x7f8c86b4ec18> | |
gc: done, 3 unreachable, 0 uncollectable, 0.0005s elapsed | |
gc: collecting generation 2... | |
gc: objects in each generation: 1 0 5831 | |
gc: done, 0.0005s elapsed | |
gc: collecting generation 2... | |
gc: objects in each generation: 1 0 5831 | |
gc: done, 0.0005s elapsed | |
gc: collecting generation 2... | |
gc: objects in each generation: 1 0 5831 | |
gc: done, 0.0005s elapsed | |
gc: collecting generation 2... | |
gc: objects in each generation: 1 0 5831 | |
gc: done, 0.0005s elapsed | |
<__main__.B object at 0x7f8c86b4ec50> | |
[[<__main__.B object at 0x7f8c86b4ec50>, {'a': <__main__.A object at 0x7f8c86b4ec18>, 'b': <__main__.B object at 0x7f8c86b4ec50>}], {'a': <__main__.A object at 0x7f8c86b4ec18>, 'b': <__main__.B object at 0x7f8c86b4ec50>}] | |
<__main__.A object at 0x7f8c86b4ec18> | |
[{'a': <__main__.A object at 0x7f8c86b4ec18>, 'b': <__main__.B object at 0x7f8c86b4ec50>}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import sys | |
import weakref | |
class A: pass | |
class B: pass | |
gc.disable() | |
gc.collect() | |
gc.set_debug(gc.DEBUG_STATS | gc.DEBUG_LEAK) | |
a = A() | |
weakref.finalize(a, print, 'finalize: a', file=sys.stderr).atexit = False | |
b = B() | |
b.a = a | |
b.b = b | |
weakref.finalize(b, print, 'finalize: b', a, file=sys.stderr).atexit = False | |
del a | |
del b | |
for _ in range(10): gc.collect() | |
gc.set_debug(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment