PDA

View Full Version : [1.1.1] grid mem leak with iexplorer (urgent...)



filipe_c
2 Oct 2007, 5:02 AM
OS :Windows XP, SP2
Browser : Iexplorer 6.0 (at least, i did not test 7.0)
Mem leak program: Drip


// Store definition
var ds = new Ext.data.Store({
reader: new Ext.data.ArrayReader({id:0}, [
{name: 'scatag' },
{name: 'pri' }
])
});

// grid definition
var colModelAlr = new Ext.grid.ColumnModel([
{id:'scatag' , header: lang['Tag'], width: 60, dataIndex: 'scatag', sortable: true,hidden:true },
{id:'pri' , header: lang['pri'], width: 40, dataIndex: 'pri', sortable: true,hidden:false }
]);

grid = new Ext.grid.Grid('alarms-grid', {
ds: ds,
cm: colModelAlr,
selModel: new Ext.grid.RowSelectionModel(),
enableColLock:false,
loadMask: true,
enableDrag: true
});

grid.render();


now i

filipe_c
2 Oct 2007, 5:12 AM
a strange thing is that if i comment the code
bt.firstChild.removeChild(bt.rows[index]);
on gridview the leak is much less... 1268 nodes...
what the hell ...




the final number of nodes is

onRemove : function(ds, record, index, isUpdate){
if(isUpdate !== true){
this.fireEvent("beforerowremoved", this, index, record);
}
var bt = this.getBodyTable(), lt = this.getLockedTable();
if(bt.rows[index]){
// bt.firstChild.removeChild(bt.rows[index]);
}
if(lt.rows[index]){
lt.firstChild.removeChild(lt.rows[index]);
}
if(isUpdate !== true){
this.stripeRows(index);
this.syncRowHeights(index, index);
this.layout();
this.fireEvent("rowremoved", this, index, record);
}
},

filipe_c
2 Oct 2007, 5:22 AM
here is the dom usage in drip...
it seems that each row is an <tr><td>...

but the
bt.firstChild.removeChild(bt.rows[index]);

does not delete the dom nodes of this tr...

look to drip...

filipe_c
2 Oct 2007, 6:54 AM
I discover the source of the problem...
removeChild in iexplorer does not work... it apeears that it keeps a reference and gc does not collect that object.

this is a probleme since extjs uses a lot removeChild...

check http://www.outofhanwell.com/ieleak/index.php?title=Fixing_Leaks
this guy show a discard element technique...


function discardElement(element) {
var garbageBin = document.getElementById('IELeakGarbageBin');
if (!garbageBin) {
garbageBin = document.createElement('DIV');
garbageBin.id = 'IELeakGarbageBin';
garbageBin.style.display = 'none';
document.body.appendChild(garbageBin);
}

// move the element to the garbage bin
garbageBin.appendChild(element);
garbageBin.innerHTML = '';
}

filipe_c
2 Oct 2007, 7:18 AM
suggest to fix leak...
tested in explorer 6.0

from http://www.outofhanwell.com/ieleak/index.php?title=Fixing_Leaks


Ext.discardElement = function (element) {
var garbageBin = document.getElementById('IELeakGarbageBin');
if (!garbageBin) {
garbageBin = document.createElement('DIV');
garbageBin.id = 'IELeakGarbageBin';
garbageBin.style.display = 'none';
document.body.appendChild(garbageBin);
}

// move the element to the garbage bin
garbageBin.appendChild(element);
garbageBin.innerHTML = '';
}
Ext.removeNode = function (node) {
if( Ext.isIE ){
Ext.discardElement(node);
}
else if(node && node.parentNode){
return node.parentNode.removeChild(node);
}
}
Ext.deleteAllChildNodes = function (node) {
var count = node.childNodes.length;
while(node.hasChildNodes()) {
Ext.removeNode(node.firstChild);
}
return count;
}


onRemove : function(ds, record, index, isUpdate){
if(isUpdate !== true){
this.fireEvent("beforerowremoved", this, index, record);
}
var bt = this.getBodyTable(), lt = this.getLockedTable();
//debugger ;
if(bt.rows[index]){
Ext.deleteAllChildNodes(bt.rows[index]);
//bt.firstChild.removeChild(bt.rows[index]);
}
if(lt.rows[index]){
Ext.deleteAllChildNodes(lt.rows[index]);
//lt.firstChild.removeChild(lt.rows[index]);
}
if(isUpdate !== true){
this.stripeRows(index);
this.syncRowHeights(index, index);
this.layout();
this.fireEvent("rowremoved", this, index, record);
}
},


The problem is that this should be updated in all removeChild ...
that a lot in ext

jsakalos
2 Oct 2007, 12:20 PM
I'm notifying Jack to take a look at this.

filipe_c
3 Oct 2007, 12:53 AM
I'm notifying Jack to take a look at this.
thanks, because i think it

filipe_c
8 Oct 2007, 1:32 AM
I'm notifying Jack to take a look at this.


NO news ?

filipe_c
30 Oct 2007, 10:24 AM
No news about this,,,
i think this is really important...

jsakalos
31 Oct 2007, 8:39 AM
A grid leak has already been added to the bug list of Ext 2.0. I cannot say now how and when fixes will be backported to 1.1.1.