-
Notifications
You must be signed in to change notification settings - Fork 470
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
Valgrind detected memory leak #891
Comments
@lygstate do you by any chance have a piece of code that can help us reproduce the valgrind result? |
Hi team, So I was not able to get the valgrind error, however I replicated the memory leak by throwing a console message in a destructor on ~AccessorCallbackData() {
std::cout<<"destructed!\n";
} And using this simple instance accessor example, the message did NOT show: #include <iostream>
#include <functional>
#include <vector>
#include "napi.h"
class Window : public Napi::ObjectWrap<Window> {
public:
static Napi::Function Init(Napi::Env env) {
Napi::Function ctor = DefineClass(env, "Window", {
ObjectWrap::InstanceAccessor("buffer", &Window::getBuffer, nullptr),
});
return ctor;
}
Window(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Window>(info) { };
private:
Napi::Value getBuffer(const Napi::CallbackInfo& info) {
return Napi::String::New(info.Env(), "buffer");
}
};
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports["Window"] = Window::Init(env);
return exports;
}
NODE_API_MODULE(addon, Init) addon.js: const x = new Window("hello");
console.log(x.buffer); When executing:
I believe the issue is in Line 3266 in 286ae21
with the check for Lines 3409 to 3426 in 286ae21
Within Lines 3277 to 3282 in 286ae21
By simply removing this
|
good catcha, I also fixed this one, also have other issues. I've create a PR for this |
Fixes: nodejs/node-addon-api#891 PR-URL: nodejs/node-addon-api#899 Fixes: nodejs/node-addon-api#891 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Fixes: nodejs/node-addon-api#891 PR-URL: nodejs/node-addon-api#899 Fixes: nodejs/node-addon-api#891 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Fixes: nodejs/node-addon-api#891 PR-URL: nodejs/node-addon-api#899 Fixes: nodejs/node-addon-api#891 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Fixes: nodejs/node-addon-api#891 PR-URL: nodejs/node-addon-api#899 Fixes: nodejs/node-addon-api#891 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
How to delete the following
new
created data?Or
node_api.h
needs expost destructor function for data?The text was updated successfully, but these errors were encountered: