Fix reference cycle that can result from objgraph.by_type#22
Merged
mgedmin merged 1 commit intomgedmin:masterfrom Jul 28, 2015
Merged
Fix reference cycle that can result from objgraph.by_type#22mgedmin merged 1 commit intomgedmin:masterfrom
mgedmin merged 1 commit intomgedmin:masterfrom
Conversation
…thout having to run the garbage collector on it.
Owner
|
Thank you for the pull request! |
mgedmin
added a commit
that referenced
this pull request
Jul 28, 2015
Fix reference cycle that can result from objgraph.by_type
mgedmin
added a commit
that referenced
this pull request
Jul 28, 2015
Owner
|
Some other functions have the same problem: count(), typestats(). I'm fixing them too. |
mgedmin
added a commit
that referenced
this pull request
Jul 28, 2015
Owner
|
objgraph 2.0.1 is out with this fix. |
Contributor
Author
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is perhaps a bit obscure, but was still biting me when trying to debug an unrelated reference cycle.
In the process of debugging I set
gc.disable()so that I can ensure that I can find the (otherwise collectable) reference cycle before it's collected.However, when running
objgraph.by_type, it seems that a reference cycle can be created between the stack frame forby_typeand itself by way of theobjectslist. Normally this would be cleaned up on the next garbage collector run, but since I'm leaving automatic garbage collection disabled it sticks around. Then when I rungc.get_referrerson one of the objects returned byby_type, I get back the hugeobjectslist as one of its referrers since it's still being tracked.Manually deleting the
objectslist at the end ofby_typeensures that any reference cycles involving it are broken and can be cleaned up before any further inspection is performed on an object's referrers.