Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created October 24, 2012 18:06
Show Gist options
  • Save 3rd-Eden/3947755 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/3947755 to your computer and use it in GitHub Desktop.
memleak?
// readStream that isn't piped in to anything
var s = require('fs').createReadStream('/dev/random');
setTimeout(function kill(){
s.destroy();
console.log('stream killed');
if ('gc' in global) {
global.gc();
console.log('Garbage collected');
}
}, 60 * 1000);
// just something silly to keep the event loop open.
setTimeout(function () {
console.log('k, tnx, ilu');
}, (60 * 1000) * 60);
// Adding the following listener doesn't help either:
//s.on('data', function (buff) {
// console.log('buffer', buff.length);
//});
// keep it running, after you get a stream killed message
// you will notice that the memory isn't dropping to like
// 30 mb ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment