Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created August 18, 2016 21:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/383021bcc0d10735fb39079df2934792 to your computer and use it in GitHub Desktop.
Save piscisaureus/383021bcc0d10735fb39079df2934792 to your computer and use it in GitHub Desktop.
var heapdump = require('heapdump');
var lastHeapUsed;
setTimeout(function() {
dump(process.memoryUsage().heapUsed);
setInterval(function() {
var heapUsed = process.memoryUsage().heapUsed;
if (heapUsed > 2*lastHeapUsed)
dump(heapUsed);
}, 5000);
}, 1);
function dump(heapUsed) {
heapdump.writeSnapshot(process.pid + '-' + (heapUsed >> 20) + '.heapsnapshot');
lastHeapUsed = heapUsed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment