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

How to properly shutdown a hxcpp DLL? #1084

Open
dazKind opened this issue Jan 1, 2024 · 0 comments
Open

How to properly shutdown a hxcpp DLL? #1084

dazKind opened this issue Jan 1, 2024 · 0 comments

Comments

@dazKind
Copy link
Contributor

dazKind commented Jan 1, 2024

I have the use-case that I build a hxcpp DLL that I load in Godot as an extension (https://hxgodot.github.io).

Each haxe-bound engine class constructs a binding object in the engine and retains the pointer to the engine data. It works great during normal runtime with some GC Root trickery, and pointers of engine objects are being released when the finalizers run.

But things get tricky when the engine is shutting down. Even after clearing the GCRoots, GC might still be holding on to an object that contains a pointer, that needs to be released in the engine. And when the finalizer finally runs, the necessary stage/environment to release the pointer is gone and the engine tracked this as a leaked object.

I noticed that the whole boot/shutdown of hxcpp is not really symmetrical and shutdown / unregister is missing. So I guess I would have to add some code that involves the GC. Do you have any clues for me on how to go about this, esp. when it comes to GC?

Ideally I would want to signal hxcpp to release everything that is still being held on, thus enabling a coordinated shutdown & release.

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

No branches or pull requests

1 participant