我将新的根节点设置到TreeStore时出现内存泄漏

时间:2012-11-14 13:30:04

标签: javascript extjs

我有这个extjs代码

Ext.application({
name: 'WebConsole',
launch: function() {
var tempStore = Ext.create('Ext.data.TreeStore',{
    autoload: false,
    proxy:{
        type: 'ajax',
        url: 'server.json',
      reader: {
          type:'json'
      }
    },
    clearOnLoad: true,
  listeners:{
    load:{
        fn: function(store)
    {
        var childs = Ext.clone(store.getRootNode().childNodes);
        treepanel.setRootNode({
        text: "Services",
        expanded: true,
        children: childs
        });
    }

            }           
}});
tempStore.load();
var runReloadTreePanel = Ext.create("Ext.util.TaskRunner");
var taskTree = {
        run: function()
        {
        tempStore.load();
        },
       interval:1000 
}

var checkbox = Ext.create('Ext.form.field.Checkbox',{
       boxLabel: 'Refresh',
       listeners :{
           change: {
                fn: function(field,newValue,oldValue){
                    if(newValue)
                    {
          runReloadTreePanel.start(taskTree);
                    }
                    else
                    {
          runReloadTreePanel.stop(taskTree);
                    }
      }
       }
        }
});
var treepanel = Ext.create('Ext.tree.Panel', {
    title: 'Services',
    collapsible: true,
    rootVisible:false,
    expanded: true,
    region:'west',
    margins: '5 0 0 0',
    width: 400,
    minSize: 100,
    maxSize: 250,
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        items: [
                checkbox           
                ]
    }],
     viewConfig: 
        {
        loadMask: false
        }
});

Ext.create('Ext.container.Viewport', {
 layout: 'fit',
    items: [
treepanel
 ]
    });
}});

我每1秒钟重新加载一次tempStore,从中获取数据并将新根设置到面板中。
问题
结果IE中的内存,Opera增长,我们有大量的内存泄漏。为什么会这样?有什么建议吗? json,我从服务器:

{text: 'Services',children:[
{text : 'JMS',leaf : false, expanded: true, children:[
{text : 'ActiveMQClient',leaf : true,icon: 'images/STARTED_icon.gif'},
{text : 'ActiveMQServer',leaf : true,icon: 'images/STARTED_icon.gif'}]},
{text : 'Routes',leaf : false, expanded: true, children:[
{text : 'Backend Emulation',leaf : false, expanded: true, children:[
{text : 'Backend Emulation[1]',leaf : true,icon: 'images/STARTED_icon.gif'},
{text : 'Backend Emulation[2]',leaf : true,icon: 'images/STARTED_icon.gif'}]},
{text : 'XEConnect',leaf : false, expanded: true, children:[
{text : 'XEConnect Inbound',leaf : false, expanded: true, children:[  
{text : 'XEConnect Inbound[1]',leaf : true,icon: 'images/STARTED_icon.gif'},
{text : 'XEConnect Inbound[2]',leaf : true,icon: 'images/STARTED_icon.gif'}]},
{text : 'XEConnect Outbound',leaf : false, expanded: true, children:[
{text : 'XEConnect Outbound[1]',leaf : true,icon: 'images/STARTED_icon.gif'},
{text : 'XEConnect Outbound[2]',leaf : true,icon: 'images/STARTED_icon.gif'}]}]}]},
{text : 'XEConnect',leaf : false, expanded: true, children:[
{text : 'CORE Server',leaf : true,icon: 'images/STARTED_icon.gif'}]}]}

0 个答案:

没有答案