Last active
February 9, 2018 23:50
-
-
Save darahayes/8802d7372905c6ec03fa6e3ca8d7ae76 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
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