Simplify cleanup logic of ForestWrapper#118
Open
vchuravy wants to merge 2 commits into
Open
Conversation
The ForestWrapper already assumed that it is going to be called in-order, otherwise the same `unique_id` would have been associated with different forests. So instead of using a dictonary we can use a FIFO. Additionally we added ourself unconditionally to the T8CODE_OBJECT_TRACKER thus ensuring that GC would never free those objects, relying on `clean_up` to finalize the objects at the end.
vchuravy
commented
May 4, 2026
Comment on lines
-171
to
-172
| In serial mode the wrapper and in consequence the t8code forest | ||
| can be finalized immediately whenever Julia's garbage collector sees fit. |
Author
There was a problem hiding this comment.
This statement was not true, since the object was always preserved in the T8Code_OBJECT_TRACKER
vchuravy
commented
May 4, 2026
| delete!(T8CODE_OBJECT_TRACKER, unique_id) | ||
| # arrays. | ||
| t8_forest_unref(Ref(w.pointer)) | ||
| w.pointer = C_NULL |
Author
There was a problem hiding this comment.
Setting the pointer to null, to avoid a double free through the same object
Collaborator
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.
The ForestWrapper already assumed that it is going to be called
in-order, otherwise the same
unique_idwould have been associated withdifferent forests. So instead of using a dictonary we can use a FIFO.
Additionally we added ourself unconditionally to the
T8CODE_OBJECT_TRACKER thus ensuring that GC would never free those
objects, relying on
clean_upto finalize the objects at the end.