The book Learning jQuery says IE has memory leak for the DOM object having a property referencing a function, and the function also referencing the DOM object, thus having a "circular reference", like this:
onload = function() {
var foo = document.getElementById('foo');
foo.onclick = function() { // DOM object foo's onclick property refers to a function
foo.innerHTML = "hello" // the function's body refers to the DOM object
} // therefore circular reference
}
IE can handle circular references for garbage collection, but not when the circular references involve both DOM object and Javascript object, because they are handled by different memory managers.
and:
[the memory leak... and] the resulting [reference] looping can't be released by IE even when we navigate away from the page.
never freed until browser is closed.
Is it true? Why does IE not release those memory even when a user leaves the page? Is it because the user may click Back
and come back to the page, and IE would like to keep the state of the page? In that case, what if the user is on the memory leak page, and then clicks Back
, and then goes to google.com? Then the page is not viewable by any Back
or Forward
, and the memory leak problem can go away without closing the browser?
Or even when the tab is closed, without closing the browser?
Does this kind of memory leak happen in IE 8 too?