More On IE Memory Leaks
I’ve been doing a little more homework on the memory problems in IE. I found a nice summation of the problem at Jibbering. It appears that the problem is through the use of closures that form circular references, meaning that one object is assigned a function that references that same object. This is especially problematic when using DOM nodes and ActiveX objects.
The problem is that the garbage collector doesn’t destroy objects unless all references to them are invalidated. The IE garbage collector (and apparently Safari’s as well) considers a circular reference as a full-fledged reference to an object and doesn’t destroy the object, leading to high memory usage. Reloading/refreshing the page just compounds the problem.
I did find one other point of view, that said this was not actually a memory leak. His words:
…the browser does NOT tear down circular references in page elements until the page is navigated away. Refreshing the page does not count as navigating away! This means that if you have a page that refreshes itself and has a closure bound to an event, you almost certainly are leaking memory every time the page refreshes itself. That memory is not a “real” leak in that it will go away eventually, but not until the browser is navigated.
The hunt for the truth continues…
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.