When deployed my node.js application hits memory related errors (i.e. FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory). I would like to profile my node locally to see what is eating up memory but am not sure where to start.
Asked
Active
Viewed 755 times
4
-
2This question is answered here: http://stackoverflow.com/questions/4918557/debugging-memory-leaks-with-node-js-server – Ryan Olds Jan 08 '12 at 17:42
-
The answer there (use profiler from node inspector) has us use something labeled "VERY EXPERIMENTAL" and not recommended by the author himself. – Aaron Silverman Jan 10 '12 at 20:35
1 Answers
2
You can use node-inspector and the v8-profiler to do this. Install it from npm:
$ npm install v8-profiler
And then use it to take heap snapshots (taken from instructions):
var profiler = require('v8-profiler');
var snapshot = profiler.takeSnapshot([name]) //takes a heap snapshot

Ankit
- 1,861
- 18
- 18
-
v8-profiler is currently broken for me: https://github.com/dannycoates/v8-profiler/issues/9 – Aaron Silverman Jan 10 '12 at 20:34
-
But when it works again this will probably be the best way, thanks! – Aaron Silverman Jan 17 '12 at 15:42