Skip to content

Instantly share code, notes, and snippets.

@eendeego
Created November 14, 2012 17:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eendeego/4073604 to your computer and use it in GitHub Desktop.
Save eendeego/4073604 to your computer and use it in GitHub Desktop.
Profiling node.js apps with Ben Noordhuis heapdump

This instructions allow you to take periodical heapdumps.

To use in your project, first install heapdump, then add the following code to your app just after requiring 'fs'.

require('heapdump');
fs.readdirSync('.').map(function (filename) {
if (filename.match(/^heapdump-/)) {
console.log(filename);
fs.unlinkSync(filename);
}
});
setInterval(function heapDumper() {
process.kill(process.pid, 'SIGUSR2');
}, 15000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment