Edit: Firefox is not doing this in the future test, but Chrome definitely does that I think it There is a bug with a new browser - for every event I / O reads chrome but not in FF.
When I load the following page in a browser under Chrome and Firefox 3) and the mouse around the mouse always grows and does not seem to be retreating at all.
This is:
- Expected behavior from a browser <
- Memory leak in the browser or
- One memory stored code the leak?
& lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // N" "http://www.w3.org/TR/html4/strict.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-8859-1" /> & Lt; Title & gt; Trial & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script & gt; Var createEl = function (i) {var el = document.createElement ("div"); Var t = document.createTextNode (i.toString ()); El.appendChild (t); T = null; El.id = i.toString (); Var fn = function (e) {}; El.addEventListener ("mouseover", fn, incorrect); //el.onmouseover = fn; FN = null; Try {return el; } Finally {el = null; } // return (L = [L]). Pop (); }; Var i, x; (I = 0; i & lt; 100; i ++) for {x = createEl (i) document. Body.appendChild (x); X = Null; } & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
(el = [el]. Pop ())
and try / end
are both, though they do or So do not seem to help - obviously because they are only for IFFI fixes.
I have also experimented with using the addEventListener and using on-the-hostover methods to add events. I've found the only way to stop memory is to comment on both lines of code.
Leaks related to memory event handlers, generally speaking, are related to enclosures in other words Attaching a function to an event handler, which points back to its element, can prevent the browser from collecting garbage either (thankfully, most new browsers have "learned the trick") and now the memory in this scenario Have not leaked, but there are very old old brows Hr that floating around there are!)
Such an enclosure could look like this:
var el = document.createElement ( "div"); Var fnOver = function (e) {el.innerHTML = "mouse over!"; }; Var fnOut = function (e) {el.innerHTML = "mouse out."; }; El.addEventListener ("mouseover", again, incorrect); El.addEventListener ("mouseout", fnOut, false); Document.getElementsByTagName ("body") [0] .appendChild (L);
The fact is that fnOver
and fnOut
reach their attached scope for reference el
One that makes an enclosure (two, in fact - one for each function) and the browser can cause leakage. Your code does not do anything like that, so there is no constellation, so there should not be a reason for a relative (browser).
Just a bumar of beta software, I think: -)
Comments
Post a Comment