Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Closures memory leak test
var functionRefs = [];
function callMeBack(callback)
{
setTimeout(callback, 100);
functionRefs.push(callback); // If I comment this, the leak dissapears!!! -> But I can't do this, it's handled by Parse
}
function start()
{
var bigArray = []; // 10 MB
for (var i = 0; i < 10 * 1024 * 1024; i++)
{
bigArray[i] = 0;
}
callMeBack(function ()
{
console.log(bigArray.length);
setTimeout(start, 100);
//bigArray = null; // If I uncomment this, the leak dissapears!!! -> And this is something I can do :)
});
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.