Skip to content

Is it possible to use Valgrind or other memory leak detector to debug native Node.js addons? #1851

New issue

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

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

Already on GitHub? # to your account

Closed
VictorQueiroz opened this issue Apr 8, 2019 · 3 comments

Comments

@VictorQueiroz
Copy link

I use Valgrind to detect memory leaks in my C/C++ code so I'm wondering if it'd be possible to do the same to my C++ code that I write to create bindings to my Node.js code. Downloading Node.js from source and building it with debug flag and then using Valgrind would be a reasonable option?

Also would be possible to integrate it with IDE like CLion? It'd definitely be something else.

Thank you in advance.

@bnoordhuis
Copy link
Member

You can and you probably don't even need to build Node.js in debug mode, just your add-on. Pass --debug to npm or node-gyp.

There's a suppression file but it's best effort and against master, it might not work (fully) against release versions.

I don't know about IDE integration, I don't use those.

@mhdawson
Copy link
Member

mhdawson commented Apr 9, 2019

Don't know about IDE integration either, but I can confirm that I've used valgrind with Node.js and addons (for example in nodejs/node#26667). I did use --debug but even without that I got useful data.

@gireeshpunathil
Copy link
Member

answered, closing.

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

No branches or pull requests

4 participants