In Internet Explorer, why does a memory leak remain even when navigating from pages?

Learning jQuery says that IE has a memory leak for a DOM object that has a property that refers to a function, and the function also refers to a DOM object, thus having a "circular reference", for example:

onload = function() { var foo = document.getElementById('foo'); foo.onclick = function() { // DOM object foo onclick property refers to a function foo.innerHTML = "hello" // the function body refers to the DOM object } // therefore circular reference } 

IE can handle circular references for garbage collection, but not when circular references include both the DOM object and the Javascript object, because they are handled by different memory managers.

and

[memory leak ... and] as a result of the [link] loop cannot be freed by IE, even when we navigate from the page.

never freed until the browser is closed.

It's true? Why doesn't IE release this memory even when the user leaves the page? Is it because the user can click Back and return to the page, and IE would like to keep the page state? In this case, what if the user is on a memory leak page and then clicks Back and then goes to google.com? Then the page cannot be viewed by any Back or Forward , and the memory leak problem can disappear without closing the browser?

Or even when the tab is closed without closing the browser?

Is there such a memory leak in IE 8?

+6
garbage-collection internet-explorer memory-leaks
source share
2 answers

Memory leaks are a class of program errors, so you basically ask: "Why is IE buggy?". The answer to this is obviously "because the programmer was wrong somewhere."

While some browsers intentionally keep the state of the page even when you move away from it (especially Opera and FF), β€œmemory leak” means memory that the program no longer uses, but forgot to free. In this case, IE ceases to care about this part of the memory, but did not say the OS (Windows), which still considers it to be "used IE". Thus, this part of the memory hangs on the no man's land until the browser is closed, because when the browser process is completed, the OS marks all the memory allocated for this process as "free".

Memory leaks are a rather insidious type of error, because the program works correctly, but gradually consumes more and more memory.

See http://en.wikipedia.org/wiki/Circular_reference and http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) for further reading on this topic.

+3
source share

The leak is there because one of the programmers of the application (in this case IE) was not able to correctly dispose of something (object, resource) that used memory.

MSDN addresses the three most common causes of leaks in managed applications :

  • Retention of references to managed objects
  • Inability to free unmanaged resources
  • Failed to delete drawing objects.
+1
source share

All Articles