I was reviewing the slides in this presentation: http://slid.es/gruizdevilla/memory
and on one of the slides, this code is presented with the suggestion that it creates a memory leak:
var a = function () {
var smallStr = 'x',
largeStr = new Array(1000000).join('x');
return function (n) {
eval(''); //maintains reference to largeStr
return smallStr;
};
}();
Closures can be another source of memory leaks. Understand what references are retained in the closure.
And remember: eval is evil
Can someone explain the issue here?