Skip to content

Instantly share code, notes, and snippets.

@ErisDS
Last active January 3, 2016 01:49
Show Gist options
  • Save ErisDS/8391533 to your computer and use it in GitHub Desktop.
Save ErisDS/8391533 to your computer and use it in GitHub Desktop.
Heapdump code. Plug this into Ghost's index.js to instrument Ghost & inspect memory usage.
var heapdump = require('heapdump');
var nextMBThreshold = 0;
function recordMemory() {
var usage = process.memoryUsage();
var memMB = usage.rss / 1048576;
console.log('MEMORY', usage);
if (memMB > nextMBThreshold) {
heapdump.writeSnapshot();
nextMBThreshold += 100;
}
}
setInterval(recordMemory, 6000 * 2);
recordMemory();
@ErisDS
Copy link
Author

ErisDS commented Jan 16, 2014

// without the heapdump

function recordMemory() {
    console.log('MEMORY', process.memoryUsage());
}

setInterval(recordMemory, 6000 * 2);
recordMemory();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment