Chrome Profiler Javascript memory leak Chrome Profiler Javascript memory leak google-chrome google-chrome

Chrome Profiler Javascript memory leak


The difference between the two profilers is that before you "destroy" leak, the Leaker variable is global and after it's not. So it's just the profiler (and the javascript engine) that doesn't work the way you describe it. Basically, you can see global variables, but not locally scoped variables. I guess it makes sense to allocate differently based on the scope. Until you set leak to null, it needs to be available to other scripts.

You can see with a minimal example how the profiler works differently based on the scope:

var Leaker = function() {};var Leaker2 = function() {};// this one is going to be in the profilervar leak = new Leaker();(function(){    // this one is not in the profiler    var leak2 = new Leaker2();    setInterval(function(){console.log(leak2)}, 500);})()