Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Object::free_instance_binding() to GDExtension #82799

Conversation

CedNaru
Copy link
Contributor

@CedNaru CedNaru commented Oct 4, 2023

I noticed that the latest Godot 4.2 beta added a new free_instance_binding function to Object.
It is only exposed to the Editor but it has uses for regular GDExtension memory management.

We would welcome that change for our Godot Kotlin binding as it makes some memory management operations easier.
One of the use cases is for example to free the JVM instance used to wrap the native object pointer when it's no longer used in the managed side of the memory. That way we don't have to wait for the native object freed to release the Kotlin wrapper as our instance binding hold a reference to the JVM instance (so far we had to convert it to a weak reference instead of removing the binding).

@CedNaru CedNaru requested review from a team as code owners October 4, 2023 17:19
@CedNaru CedNaru force-pushed the feature/expose_free_instance_binding branch from 4b47937 to 0a246e9 Compare October 4, 2023 17:24
@CedNaru CedNaru changed the title Expose Object::free_instance_binding to GDExtension Expose Object::free_instance_binding() to GDExtension Oct 4, 2023
@dsnopek dsnopek added this to the 4.x milestone Oct 4, 2023
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

This use case makes sense to me! The code looks good - this is basically just exposing functionality that was already there, so I think it's pretty safe.

I don't know if the production team will be OK with merging this for Godot 4.2, given that the feature freeze is imminent, but if it doesn't make that cut off, this can be an early 4.3 addition.

@dsnopek dsnopek modified the milestones: 4.x, 4.2 Oct 4, 2023
@akien-mga akien-mga merged commit c7ed5d7 into godotengine:master Oct 5, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants