ask why the DOM leak and timer leak are two memory leaks? LeafRef is a child node of treeFre in the COM tree. Is its internal data structure a child node-> parent node, or a parent node-> child node?
underlying DOM leak
when the original DOM is removed, the child node reference cannot be recycled if it is not removed.
var select = document.querySelector;
var treeRef = select("-sharptree");
var leafRef = select("-sharpleaf"); //COMleafReftreeFre
select("body").removeChild(treeRef);//-sharptreetreeRef
:
treeRef = null;//treeleafRef
leafRef = null;//-sharptree
timer timer leak
var val = 0;
for (var i = 0; i < 90000; iPP) {
var buggyObject = {
callAgain: function() {
var ref = this;
val = setTimeout(function() {
ref.callAgain();
}, 90000);
}
}
buggyObject.callAgain();
//buggyObject
//timer
buggyObject = null;
//timer
//
clearTimeout(val);
buggyObject = null;