Skip to content

Reset reference counter to fix memory leak - #350

Closed
PhilWun wants to merge 1 commit into
godotengine:masterfrom
PhilWun:fix_memory_leak
Closed

PhilWun wants to merge 1 commit into
godotengine:masterfrom
PhilWun:fix_memory_leak

Conversation

@PhilWun

@PhilWun PhilWun commented Nov 22, 2019

Copy link
Copy Markdown

This needs to be merged after godotengine/godot-headers#60 is merged.
This is part of the fix for #215.

@BastiaanOlij

Copy link
Copy Markdown
Collaborator

Not sure if this is safe in all conditions... Need some more opinions

@BastiaanOlij
BastiaanOlij requested review from BastiaanOlij and akien-mga and removed request for BastiaanOlij January 30, 2020 10:01
@BastiaanOlij BastiaanOlij added the bug This has been identified as a bug label Jan 30, 2020
Comment thread include/core/Godot.hpp
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; \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread include/core/Godot.hpp
Name *instance = godot::as<Name>(script->new_()); \
godot::Reference *ref = (godot::Reference *)instance; \
if (ref) { \
ref->reset_ref(); \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does reset_ref() come from? I don't see it in Reference.

@Zylann

Zylann commented Jun 5, 2020

Copy link
Copy Markdown
Collaborator

Should no longer be needed after #408

@Zylann

Zylann commented Aug 14, 2020

Copy link
Copy Markdown
Collaborator

Closing since the cause of the leak was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archived bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants