4

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.

Aaron Silverman
  • 22,070
  • 21
  • 83
  • 103
  • 2
    This 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 Answers1

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