Hard using IE Javascript leak detectors

Microsoft IE6 and IE7 browsers suffer from memory leaks when certain Javascript code templates are used. I found a lot of information about what the leakage patterns were in the early days of IE6. However, I understand that many (but not all) of them have been fixed in IE7 and in the service pack for IE6. I cannot find a reliable source of information about which leaks still remain in those patched versions of IE6 and IE7.

There are several tools for detecting leakage patterns. But I can't seem to use them the way I want!

  • Microsoft's Memory Leak Detector (V2) does not detect leaks at all in my code, even when I use patterns that should leak. This may be due to the fact that I am running IE8 - is there any way that does not cause a headache to make it pretend to be IE6 or IE7?

  • Blob and sIEve seem to find tons of leaks of diversity of โ€œorphansโ€. Of course, these should be false positives - in fact, every element that I add to the document, then delete again, is listed, and I do not believe that I keep links to them. And if they are real, how can I find where in my code they flow? Tools have a โ€œpropertyโ€ property that does not show anything, making it broken. Again, I don't know if these leaks are relevant for IE6 or IE7 or just for IE8, which is the version of IE that I installed.

Therefore, I would really like to know what types of memory leaks still remain a problem with patched versions of IE6 and IE7, and how to efficiently find them in my live code using tools that will help me.

Any help?

+7
javascript memory-leaks internet-explorer-7 internet-explorer-6
source share
1 answer

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.

+2
source share

All Articles