Skip to content

Instantly share code, notes, and snippets.

@cmbuckley
Created April 9, 2018 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmbuckley/a60380175b33b3efdc525daefa2a50f2 to your computer and use it in GitHub Desktop.
Save cmbuckley/a60380175b33b3efdc525daefa2a50f2 to your computer and use it in GitHub Desktop.
Basic Node.js Memory Consumption (https://stackoverflow.com/a/45904781/283078)
let maxConsumption = 0;
process.nextTick(() => {
let memUsage = process.memoryUsage();
if (memUsage.rss > maxConsumption) {
maxConsumption = memUsage.rss;
}
});
process.on('exit', () => {
console.error('Max memory consumption: ' + (maxConsumption / 1048576).toFixed(3) + ' MiB');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment