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
JS SWIG: C++ destructor not being called on exit #329
Comments
|
I'm not sure whether the destructor for JavaScript was ever run on exit. I'm running Ubuntu 14.04 on a 64-bit machine. |
|
I don't think you can in general rely on the C++ destructor getting called on process exit for bindings in garbage collected target languages - that's not something SWIG can really control as it is down to the target language whether the proxy object gets destroyed (and finalised if that's a separate stage) in this situation, which is what's needed to call the C++ destructor. It seems with node it doesn't. Looking at
So for node it seems the C++ destructor only gets triggered if/when GC runs and finalises the object after a However adding an explicit
So for some reason it seems the GC fails to reclaim both the objects here. |
|
Perhaps the way to resolve this then is to expose the existing |
Steps to reproduce:
compile and install SWIG
run make check-examples
go to Examples/javascript/class
open runme.js and replace the top line with
var example = require("./build/Release/example");
Run the example
Note that it says that 2 shapes remain even after all the objects were destroyed.
We're running into the same issue using SWIG.
We need the destructor to be called because our destructors are cleaning up important state behind-the-scenes. It'd be a shame to have to provide interfaces to clean up everything just because the SWIG destructor isn't working.
If there were at least an interface to call the destructor, this bug wouldn't be as bad. But there's no delete_class function (note that python has new_class and delete_class functions).
The text was updated successfully, but these errors were encountered: