0

Do you know of any good way to identify all the orphan nodes and remove them from DOM?

My problem is that i have a huge application with many controls and some of them are orphans and cause memory leaks.

So is there a good way fix that?

Thanks

P.S according to sIEve documentation

Orphan: if the value in this column is “Yes” then the element is not attached to the document.body. IE then it is a orphan node. In IE this Elements can leak as well so special care should be taken on this kinds of elements. For example clearing/setting the innerHTML of orphan nodes will cause pseudo leaks. Also orphan nodes will not fire ‘onpropertychange’ events. (Zahid Riaz)

4

1 回答 1

0

我有一个想法让你用 sIEve 进行测试:

如果您要这样创建 DOM 元素: $('body').append('<div>foo</div>');

尝试这样做[而不是]:

var elm = document.createElement('div');
elm.innerHTML = 'foo';
$(document.body).append(elm); //or document.body.appendChild(elm);

然后再次运行内存泄漏检查插件,看看会发生什么。(我个人很好奇。)

于 2013-10-31T18:21:15.047 回答