Skip to content

Instantly share code, notes, and snippets.

@hezi
Created November 23, 2015 12:03
Show Gist options
  • Save hezi/0113594f32a981010933 to your computer and use it in GitHub Desktop.
Save hezi/0113594f32a981010933 to your computer and use it in GitHub Desktop.
var memwatch = require('memwatch-next');
var heapdump = require('heapdump');
memwatch.on('leak', function(info) {
console.error(info);
var file = '/tmp/myapp-' + process.pid + '-' + Date.now() + '.heapsnapshot';
heapdump.writeSnapshot(file, function(err){
if (err) console.error(err);
else console.error('Wrote snapshot: ' + file);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment