IE6中释放form节点遇到的问题

在尝试修改Ext库,完善内存释放时发现
不管怎么改,form节点都一直释放不掉
自己写例子时,就算创建了dom节点后只赋给一个变量,sIEve显示的引用也有3个
抓狂了很久以后,上网查了下资料,发现是IE在作怪:
http://blog.archive.jpsykes.com/92/ie6-form-tag-orphans/index.html
作者也试过很多办法来清除,无一例外全失败了。

[quote]Approaches Tested

* innerHTML on parent (most common garbage collection)
* Using removeNode, rather than removeChild
* Using replaceNode before removing it
* Resetting all variables before removing it
* Giving it a HasLayout (I was desperate)
* Setting AutoComplete to off on the form
* collectGarbage()
* Crockfords Purge
* …
[/quote]

后面给的一个例子,其实是重用form节点:

function MyForm() {
this.InstanceId = ''+MyForm.InstanceCounter++;
MyForm.Instances[this.InstanceId] = this;
for( var key in MyForm.Recycle ) {
this.Node = MyForm.Recycle[key];
delete MyForm.Recycle[key];
}
if( this.Node==null ) {
this.Node = document.createElement('FORM');
}
this.Node.InstanceId = this.InstanceId;
}

MyForm.prototype.InstanceId = null;
MyForm.prototype.Node = null;

MyForm.prototype.destroy = function() {
if( this.Node.parentNode ) this.Node.parentNode.removeChild(this.Node);
MyForm.Recycle[this.InstanceId] = this.Node;
delete MyForm.Instances[this.InstanceId];
this.Node = null;
}

MyForm.InstanceCounter = 1;
MyForm.Instances = {};
MyForm.Recycle = {};

// create and destroy 10000 forms
var a;
for( var i = 0; i <= 5000; i++){

//create a new form
var b = new MyForm();
// add the new form to the body
var a = document.body.appendChild(b.Node);
//destroy the form
b.destroy();
//break;

}


无奈中。。。又不敢直接修改Ext框架的逻辑
看在这个节点占用内存也不多的面子上,不管它了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值