1

every one! I use tablpanel in extjs4,found the memory in IE8 didn't reduce when remove the panel in tabpanel,and also raised when add the panel again.so I write a test as below:

Ext.onReady(function() {
var currentItem;
var tabs = Ext.createWidget('tabpanel', {
    renderTo: 'tabs',
    resizeTabs: true,
    enableTabScroll: true,
    width: 600,
    height: 250,
    defaults: {
        autoScroll:true,
        bodyPadding: 10
    }
});

var __my_task = '';
var i = 0;
try{
    __my_task = {
            run: function(){
                if (i % 2 == 0){
                    for(var j = 0; j < 10; j++){
                        addTab(true);
                    }
                }else{
                    var items = [];

                    tabs.items.each(function(item){
                        if(item.closable){
                            if(!false || item != this.item){
                                items.push(item);
                            }
                        }
                    }, this);

                    Ext.each(items, function(item){
                        tabs.remove(item);
                        item.destroy();
                    }, this);
                } // else
                i ++;
            },
            interval: 300
    }
    Ext.TaskManager.start(__my_task);
}catch(e){}

// tab generation code
var index = 0;
function addTab (closable) {
    ++index;
    tabs.add(Ext.create('Ext.tree.Panel',{
        title: 'New Tab ' + index,
        iconCls: 'tabs',
        closable: !!closable
    }));
}

});

run it in IE8,the memory will raised so quickly,my code is wrong ? any question for me, thanks!

mack_ma
  • 11
  • 1

1 Answers1

0

IMO it's hardly to evaluate if there is memory leak in Javascript (Extjs written in JS as you know). The object may be deleted with delete() (destroy() will use it) but cannot sure when the memory will be actually released.

You can find more about Javascript garbage collector in Deleting or setting to null and Javascript garbage collection

Community
  • 1
  • 1
U and me
  • 730
  • 5
  • 13