Last active
August 29, 2015 14:26
-
-
Save wearhere/5765be04d9f1bd50a3fa to your computer and use it in GitHub Desktop.
Simple harness to exercise a memory leak in Node. Copied from https://github.com/alexeypetrushin/synchronize/pull/32, credit @d3m3vilurr.
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
var immediately = function(cb) { | |
sync.fiber(function() { | |
setImmediate(sync.defer()); | |
sync.await(); | |
}, cb); | |
}; | |
function test(m, cb) { | |
if (m-- === 0) return cb(); | |
immediately(function(err) { | |
if (err) return cb(err); | |
if (m % 1000 === 0) { | |
console.log(m + ": " + JSON.stringify(process.memoryUsage())); | |
} | |
test(m, cb); | |
}); | |
} | |
test(100000000, function(err) { | |
if (err) throw err; | |
console.log("done"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment