Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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, '');
console.log('Server running at 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