Created
June 30, 2014 10:37
-
-
Save cprcrack/b592e0d8905c5706effd to your computer and use it in GitHub Desktop.
Closures memory leak test
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 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