Reset reference counter to fix memory leak#350
Closed
PhilWun wants to merge 1 commit intogodotengine:masterfrom
Closed
Reset reference counter to fix memory leak#350PhilWun wants to merge 1 commit intogodotengine:masterfrom
PhilWun wants to merge 1 commit intogodotengine:masterfrom
Conversation
dd95139 to
f7a2dde
Compare
f7a2dde to
4912229
Compare
Collaborator
|
Not sure if this is safe in all conditions... Need some more opinions |
This was referenced Apr 25, 2020
Zylann
reviewed
May 29, 2020
| script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *)godot::gdnlib)); \ | ||
| script->set_class_name(#Name); \ | ||
| Name *instance = godot::as<Name>(script->new_()); \ | ||
| godot::Reference *ref = (godot::Reference *)instance; \ |
Collaborator
There was a problem hiding this comment.
Should not use C-style cast. This will "always succeed", even when instance isn't a reference, resulting in undefined behavior. Use Object::cast_to instead.
Zylann
reviewed
May 29, 2020
| Name *instance = godot::as<Name>(script->new_()); \ | ||
| godot::Reference *ref = (godot::Reference *)instance; \ | ||
| if (ref) { \ | ||
| ref->reset_ref(); \ |
Collaborator
There was a problem hiding this comment.
Where does reset_ref() come from? I don't see it in Reference.
Collaborator
|
Should no longer be needed after #408 |
Collaborator
|
Closing since the cause of the leak was fixed. |
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 needs to be merged after godotengine/godot-headers#60 is merged.
This is part of the fix for #215.