Created
April 11, 2018 18:39
-
-
Save jfromaniello/6078fb018431ab13552525e358cd8ce1 to your computer and use it in GitHub Desktop.
This file contains 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 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