JavaScript 内存回收散记

xxx.innerHTML = '';  很重要,目前来看是最有效果的内存回收处理方式 。

 

http://birdshome.cnblogs.com/archive/2006/05/28/IE_MemoryLeak.html

 

Ext 的回收方式:

http://fins.iteye.com/blog/172263

 

removeNode : isIE ? function(){   
    var d;   
    return function(n){   
        if(n && n.tagName != 'BODY'){   
            d = d || document.createElement('div');   
            d.appendChild(n);   
            d.innerHTML = '';   
        }   
    }   
}() : function(n){   
    if(n && n.parentNode && n.tagName != 'BODY'){   
        n.parentNode.removeChild(n);   
    }   
}

 

jQuery 简单的模仿处理:

http://www.iteye.com/topic/230695

 

jQuery.fn.removeNode = function(){   
            var d;   
            return function(){   
                if(this[0] && this[0].tagName != 'BODY'){   
                    d = d || document.createElement('div');   
                    d.appendChild(this[0]);   
                    d.innerHTML = '';   
                }   
            }   
        }(); 

// 先注册removeNode 
// 之后再通过$('div').removeNode();就可以了。 
// 不过没有清除与之相关的事件和expando中加入的data,还是不完善

 

 

你可能感兴趣的:(JavaScript,jquery,Blog,IE,ext)