-
Notifications
You must be signed in to change notification settings - Fork 462
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
Memory management questions #550
Comments
Simply put, the v8 engine works with reference counting for garbage collection. The Classes that extend |
One small correction. I don't think that V8 uses reference counting, but that does not change the comment that if we use the method across methods, that we need to either have a reference to it in a live JavaScript Object or tell V8 that it needs to be kept alive. |
Sure I understand now, still to complete a 100% shutdown of the module, some Uninit() method should dereference all these static properties then? |
@marco-ms The life cycle of Node.js native addons coincides with that of the Node.js environment. This means that once a Node.js module is loaded, it is not unloaded unless the Node.js environment terminates. For the main thread, this means that modules are unloaded only when the process terminates. For worker threads, this means that modules are unloaded when the worker thread terminates. Until recently, strong references and weak references that were not garbage collected up until environment exit were not deleted. This changes with nodejs/node#28428 having landed. Now the environment will make one final pass over all remaining references and delete them before exiting. |
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made. |
I'm going to close this as there has not been a response since the last response quite some time ago. Please let us know if you think that was not the right thing to do. |
SuppressDestructor
is used often in the object wrap examples, like:https://github.com/nodejs/node-addon-api/blob/master/doc/object_wrap.md
But what exactly means this comment? I honestly don't understand if I have to manage the life cycle of any object created by this code.
2. Similarly if using a
Napi::FunctionReference
created withNapi::Persistent()
and assigned to a class member to call a JS callback at any point in time, should the code take care of dereferencing it at some point?https://github.com/nodejs/node-addon-api/blob/master/doc/function_reference.md
The text was updated successfully, but these errors were encountered: