Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created April 11, 2018 18:39
Show Gist options
  • Save jfromaniello/6078fb018431ab13552525e358cd8ce1 to your computer and use it in GitHub Desktop.
Save jfromaniello/6078fb018431ab13552525e358cd8ce1 to your computer and use it in GitHub Desktop.
var profiler = require('v8-profiler');
process.on('SIGUSR2', () => {
const snapshot = profiler.takeSnapshot();
const fileName = `/tmp/my-project-${Date.now()}.heapsnapshot`;
snapshot.export()
.pipe(fs.createWriteStream(fileName))
.on('finish', () => {
console.log(`snapshot ${fileName} has been stored`);
snapshot.delete();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment