<script type="text/javascript" charset="utf-8">
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 <= 10000; i++){
//create a new form
var b = new MyForm();
alert(b.Node)
// add the new form to the body
var a = document.body.appendChild(b.Node);
//destroy the form
b.destroy();
break;
}
</script>