Created
June 27, 2015 01:17
-
-
Save robey/de6717a41734d802c864 to your computer and use it in GitHub Desktop.
test case for memory leak while recursing a while-loop in bluebird
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 Promise = require('bluebird'); | |
function stream() { | |
var active = true; | |
var count = 0; | |
var loop = function () { | |
if (!active) return; | |
count++; | |
if (count % 100000 === 0) console.log((process.memoryUsage().heapUsed / (1024*1024)).toFixed(2), "mb", count / 100000); | |
return get().then(function (v) { | |
return loop(); | |
}).catch(function (error) { | |
active = false; | |
}); | |
}; | |
return loop(); | |
} | |
function get() { | |
return Promise.resolve(false).then(function () { return false; }); | |
} | |
stream(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment