I do not think there is an effective tool for detecting memory leaks. However, there is a piece of software that can be used to emulate IE 6-7-8 on your PC called IE Tester .
The most common Internet Explorer leak was interaction with JScript.
When the DOM object contains a reference to the JavaScript object (such an event is a control function), and when this JavaScript object contains a reference to this DOM object, then the cyclic structure. - http://javascript.crockford.com/memory/leak.html
This looping structure is what IE has tough times with. You must understand how circular links are formed (through closure). The first step is to clean up your DOM elements before they are deleted.
This can be done using a common function:
function purge(d) { var a = d.attributes, i, l, n; if (a) { l = a.length; for (i = 0; i < l; i += 1) { n = a[i].name; if (typeof d[n] === 'function') { d[n] = null; } } } a = d.childNodes; if (a) { l = a.length; for (i = 0; i < l; i += 1) { purge(d.childNodes[i]); } } }
Each time you remove items from the DOM, you first need to use purge . You can even write a wrapper for this
function safeRemove(el) { purge(el); el.parentNode.removeChild(el); }
Of course, this is just a starting point, as it will not help you with links in other places (for example, DOM2 event handlers or elsewhere, although closing). You need to check the places where you delete items and find out which functions reference them.
This issue seems to still exist in IE 6-7-8.
galambalazs
source share