Skip to content

Instantly share code, notes, and snippets.

@shanselman
Created March 28, 2017 23:06
Show Gist options
  • Select an option

  • Save shanselman/22498257d12bab0906c1903a30edcd4c to your computer and use it in GitHub Desktop.

Select an option

Save shanselman/22498257d12bab0906c1903a30edcd4c to your computer and use it in GitHub Desktop.
app.get('/dumpme', function (req, res) {
var fs = require('fs'),
ws = fs.createWriteStream('debugdump/'+Date.now() + '.heapsnapshot'),
profiler = require('v8-profiler'),
snapshot = profiler.takeSnapshot(),
callback = ws.end.bind(ws);
snapshot.serialize(function(data) {
ws.write('' + data);
}, callback);//begin cpu profiling
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment