Create a gist now

Instantly share code, notes, and snippets.

Embed
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