-
-
Save mjurincic/e6e9285403f2c926eaad2710d2c9f62e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const http = require('http'); | |
const memwatch = require('memwatch-next'); | |
const heapdump = require('heapdump'); | |
var server = http.createServer((req, res) => { | |
for (var i=0; i<1000; i++) { | |
server.on('request', function leakyfunc() {}); | |
} | |
res.end('Hello World\n'); | |
}).listen(1337, '127.0.0.1'); | |
server.setMaxListeners(0); | |
console.log('Server running at http://127.0.0.1:1337/. Process PID: ', process.pid); | |
memwatch.on('leak', (info) => { | |
console.error('Memory leak detected:\n', info); | |
heapdump.writeSnapshot((err, filename) => { | |
if (err) console.error(err); | |
else console.error('Wrote snapshot: ' + filename); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developer.chrome.com/devtools/docs/heap-profiling