Created
August 18, 2016 21:42
-
-
Save piscisaureus/383021bcc0d10735fb39079df2934792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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