console-shim icon indicating copy to clipboard operation
console-shim copied to clipboard

Memory leak fix

Open jbadeau opened this issue 11 years ago • 6 comments

The following is a memory leak fix that occurs in some browsers when refreshing.

Cheers, Jose

jbadeau avatar May 29 '13 14:05 jbadeau

Klaus Reimer » console-shim #13 SUCCESS This pull request looks good (what's this?)

buildhive avatar May 29 '13 14:05 buildhive

I'm unaffiliated with this project, but I'm curious to know how using window inside (function() { ... })()causes a memory leak and replacing it with (function(global) { ... })(window) fixes it?

cpburnz avatar Sep 25 '14 18:09 cpburnz

@cpburnz as far as I understand it, the problematic part is:

var console = (/** @type {Object} */ window.console);

Some versions of IE can't dereference the "console" var, thus leaking it.

I don't think using window from the globals arg or directly does make any difference as far as the leak itself is concerned, though.

dmp42 avatar Sep 25 '14 19:09 dmp42

@dmp42 I'm not sure what dereferencing means in the context of Javascript. So by running:

var console = window.console;

That causes IE to leak its reference to the console object which persists between page reloads?

cpburnz avatar Sep 26 '14 18:09 cpburnz

Yes, doing so inside a closure may cause certain IE versions to not free the object between page results.

dmp42 avatar Sep 26 '14 21:09 dmp42

Why was it not merged?

evil-shrike avatar Nov 16 '16 10:11 evil-shrike