4

I'm facing a memory leak, and while looking for the problem, wondered if there was some way in Node.js to find the memory allocated to a JavaScript Object. Node provides a way to find the overall heap and stack space, but I couldn't find anything in the documentation or online to find the space for a specific object.

Given the way variables work, it shouldn't be hard to write something within node to find the size, but I was wondering if something, maybe a JavaScript function, already exists to do it?

2
  • 1
    There's some kind of memory management plugin for node.js. Maybe in the v8 toolchain
    – Raynos
    Feb 11, 2011 at 17:35
  • Chips. I think I pressed the wrong button. This did not deserve down-vote, but upvote!
    – Alfred
    Dec 31, 2012 at 1:42

1 Answer 1

5

There's Node-Profiler you could use to take 2 heap snapshot and search for large objects by comparing their values.

2
  • Node.js has actually no built-in function, but Node-Profiler uses the profiling options of V8 - the engine node.js is built on, so it's some kind of "built-in"
    – Tobias P.
    Feb 20, 2011 at 17:40
  • 1
    For people who find this in 2015 and after: Node-Profile is now obsolete. Jun 20, 2015 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.