:: Forum >> Version 2 >>

about memory release

More information on this topic is available in the documentation section: /general.faq.releases/.

I have lots pages from server, When I load grid's data again and again, how can I release memory?

data=null?
grid.on... = null?
grid=null?

...?
Killee
Tuesday, October 18, 2005
Why do you think that there is a memory problem? If you are replacing data in a JavaScript array, the browser handles the memory and there isn't much you can do except possibly set the array to null prior to assigning more info to it. Are you creating new grids every time?
Jim Hunter
Tuesday, October 18, 2005
Yes, I create two grids every time. It's a dynamic UI. And I found there are some memory leak in IE6.
Killee
Tuesday, October 18, 2005
My entire application is dynamic and I never reload the page and I ran a test that created/destroyed thousands of grids and I saw no noticeable memory issues in IE6.0 other then the ones that are inherant already. How are you 'reloading' the data? Show me some source code on how you are doing it.
Jim Hunter
Wednesday, October 19, 2005

<html>
<
head>
    <
script src="../../runtime/lib/aw.js"></script>
    <
link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</
head>
<
body>

<
script>
var 
grid = function()
{
};
grid.prototype.create = function()
{
//data    
    
this.data this.getData();
    
this.headers this.getHeaders();

    
this.obj = new AW.UI.Grid;

    
this.obj.setId("myGrid"+Math.random());
    
this.obj.setVirtualMode(false);
    
this.obj.setControlSize(600300);
    
    
this.obj.setColumnCount(this.headers.length);
    
this.obj.setHeaderText(this.headers);
    
    
this.obj.setRowCount(this.data.length);
    
this.obj.setCellText(this.data);

    
this.obj.setSelectorVisible(true);
    
this.obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

    return 
this.obj.toString();
};
grid.prototype.dispose = function()
{
    
this.data null;
    
this.headers null;
    
this.obj null;
}
grid.prototype.getData = function()
{
    var array =
        [
        [
"MSFT","Microsoft Corporation""314,571.156""32,187.000""55000","MSFT","Microsoft Corporation""314,571.156""32,187.000""55000"],
        [
"ORCL""Oracle Corporation""62,615.266""9,519.000""40650","ORCL""Oracle Corporation""62,615.266""9,519.000""40650"],
        [
"SAP""SAP AG (ADR)""40,986.328""8,296.420""28961","SAP""SAP AG (ADR)""40,986.328""8,296.420""28961"],
        [
"CA""Computer Associates Inter""15,606.335""3,164.000""16000","CA""Computer Associates Inter""15,606.335""3,164.000""16000"],
        [
"ERTS""Electronic Arts Inc.""14,490.895""2,503.727""4000","ERTS""Electronic Arts Inc.""14,490.895""2,503.727""4000"],
        [
"SFTBF""Softbank Corp. (ADR)""14,485.840"".000""6865","SFTBF""Softbank Corp. (ADR)""14,485.840"".000""6865"],
        [
"VRTS""Veritas Software Corp.""14,444.272""1,578.658""5647","VRTS""Veritas Software Corp.""14,444.272""1,578.658""5647"],
        [
"SYMC""Symantec Corporation""9,932.483""1,482.029""4300","SYMC""Symantec Corporation""9,932.483""1,482.029""4300"],
        [
"INFY""Infosys Technologies Ltd.""9,763.851""830.748""15400","INFY""Infosys Technologies Ltd.""9,763.851""830.748""15400"],
        [
"INTU""Intuit Inc.""9,702.477""1,650.743""6700","INTU""Intuit Inc.""9,702.477""1,650.743""6700"],
        [
"ADBE""Adobe Systems Incorporate""9,533.050""1,230.817""3341","ADBE""Adobe Systems Incorporate""9,533.050""1,230.817""3341"],
        [
"PSFT""PeopleSoft, Inc.""8,246.467""1,941.167""8180""PSFT""PeopleSoft, Inc.""8,246.467""1,941.167""8180"],
        [
"SEBL""Siebel Systems, Inc.""5,434.649""1,417.952""5909""SEBL""Siebel Systems, Inc.""5,434.649""1,417.952""5909"],
        [
"BEAS""BEA Systems, Inc.""5,111.813""965.694""3063""BEAS""BEA Systems, Inc.""5,111.813""965.694""3063"],
        [
"SNPS""Synopsys, Inc.""4,482.535""1,169.786""4254""SNPS""Synopsys, Inc.""4,482.535""1,169.786""4254"],
        [
"CHKP""Check Point Software Tech""4,396.853""424.769""1203""CHKP""Check Point Software Tech""4,396.853""424.769""1203"],
        [
"MERQ""Mercury Interactive Corp.""4,325.488""444.063""1822""MERQ""Mercury Interactive Corp.""4,325.488""444.063""1822"],
        [
"DOX""Amdocs Limited""4,288.017""1,427.088""9400""DOX""Amdocs Limited""4,288.017""1,427.088""9400"],
        [
"CTXS""Citrix Systems, Inc.""3,946.485""554.222""1670""CTXS""Citrix Systems, Inc.""3,946.485""554.222""1670"],
        [
"KNM""Konami Corporation (ADR)""3,710.784"".000""4313""KNM""Konami Corporation (ADR)""3,710.784"".000""4313"],
        [
"MSFT","Microsoft Corporation""314,571.156""32,187.000""55000","MSFT","Microsoft Corporation""314,571.156""32,187.000""55000"],
        [
"ORCL""Oracle Corporation""62,615.266""9,519.000""40650","ORCL""Oracle Corporation""62,615.266""9,519.000""40650"],
        [
"SAP""SAP AG (ADR)""40,986.328""8,296.420""28961","SAP""SAP AG (ADR)""40,986.328""8,296.420""28961"],
        [
"CA""Computer Associates Inter""15,606.335""3,164.000""16000","CA""Computer Associates Inter""15,606.335""3,164.000""16000"],
        [
"ERTS""Electronic Arts Inc.""14,490.895""2,503.727""4000","ERTS""Electronic Arts Inc.""14,490.895""2,503.727""4000"],
        [
"SFTBF""Softbank Corp. (ADR)""14,485.840"".000""6865","SFTBF""Softbank Corp. (ADR)""14,485.840"".000""6865"],
        [
"VRTS""Veritas Software Corp.""14,444.272""1,578.658""5647","VRTS""Veritas Software Corp.""14,444.272""1,578.658""5647"],
        [
"SYMC""Symantec Corporation""9,932.483""1,482.029""4300","SYMC""Symantec Corporation""9,932.483""1,482.029""4300"],
        [
"INFY""Infosys Technologies Ltd.""9,763.851""830.748""15400","INFY""Infosys Technologies Ltd.""9,763.851""830.748""15400"],
        [
"INTU""Intuit Inc.""9,702.477""1,650.743""6700","INTU""Intuit Inc.""9,702.477""1,650.743""6700"],
        [
"ADBE""Adobe Systems Incorporate""9,533.050""1,230.817""3341","ADBE""Adobe Systems Incorporate""9,533.050""1,230.817""3341"],
        [
"PSFT""PeopleSoft, Inc.""8,246.467""1,941.167""8180""PSFT""PeopleSoft, Inc.""8,246.467""1,941.167""8180"],
        [
"SEBL""Siebel Systems, Inc.""5,434.649""1,417.952""5909""SEBL""Siebel Systems, Inc.""5,434.649""1,417.952""5909"],
        [
"BEAS""BEA Systems, Inc.""5,111.813""965.694""3063""BEAS""BEA Systems, Inc.""5,111.813""965.694""3063"],
        [
"SNPS""Synopsys, Inc.""4,482.535""1,169.786""4254""SNPS""Synopsys, Inc.""4,482.535""1,169.786""4254"],
        [
"CHKP""Check Point Software Tech""4,396.853""424.769""1203""CHKP""Check Point Software Tech""4,396.853""424.769""1203"],
        [
"MERQ""Mercury Interactive Corp.""4,325.488""444.063""1822""MERQ""Mercury Interactive Corp.""4,325.488""444.063""1822"],
        [
"DOX""Amdocs Limited""4,288.017""1,427.088""9400""DOX""Amdocs Limited""4,288.017""1,427.088""9400"],
        [
"CTXS""Citrix Systems, Inc.""3,946.485""554.222""1670""CTXS""Citrix Systems, Inc.""3,946.485""554.222""1670"],
        [
"KNM""Konami Corporation (ADR)""3,710.784"".000""4313""KNM""Konami Corporation (ADR)""3,710.784"".000""4313"]        
    ];
  return array;
};
grid.prototype.getHeaders = function()
{
    var 
= ["Ticker""Company Name""Market Cap.""$ Sales""Employees""Ticker""Company Name""Market Cap.""$ Sales""Employees"];
    return 
a;
}
</
script>
<
div id="container" style="width:602px; height:302px; border: solid 1px black;">

</
div>

<
div id="time">time:</div>

<
script>

    var 
button = new AW.UI.Button;
    
button.setControlText("100 times");
    
document.write(button);
    
button.onClick = function(){
        var 
div;
        var 
gridIns ;
        
div document.getElementById("container");

        for(var 
i=0i100; ++i)
        {
            
gridIns = new grid();
            
div.innerHTML gridIns.create();
            
gridIns.dispose();
            
div.innerHTML "";
        }
    
        
gridIns=null;
        
div null;
        
        
alert("ok");
    }

    var 
button2 = new AW.UI.Button;
    
button2.setControlText("create one");
    
document.write(button2);
    
button2.onClick = function(){
        var 
t1=new Date()
        
        var 
div;
        var 
gridIns ;
        
div document.getElementById("container");
        
        
gridIns = new grid();
        
div.innerHTML gridIns.create();
        
gridIns.dispose();
        
gridIns=null;
        
div null;
        
        
document.getElementById("time").innerHTML "time:"+(new Date() - t1);
    }

    var 
button3 = new AW.UI.Button;
    
button3.setControlText("delete one");
    
document.write(button3);
    
button3.onClick = function(){
        var 
div;
        
div document.getElementById("container");
        
div.innerHTML "";
        
div null;
    }
</
script>
</
body>
</
html>
 
OK, Jim, try it
Thursday, October 20, 2005
I feel you test is completely skewed. I ran it just like you have and saw a 40 meg leak when I ran the 100 times test once. I then went in and looked at your code and did not like what I saw. Why are you trying to destroy the grid each time when your post is claiming a memory leak when reloading data? So I changed the code to not create the grid over and over, just clear and re-load the data. Then I also desctroyed the temporary data array you are creating in your getData function and low and behold, the 'leak' almost went away. I think that if you simplify your code and simply create a single grid, re-use the same data array (don't keep creating it over and over), and clear/re-load the data only durring your itteration, you will find that the grid performs quite nice.
When doing testing like you are here, start simple and test just the thing you want to test. What showed up in your test, that you assumed were grid data issues, were IE issues and JavaScript issues. I suggest starting over with your test, keep it simple, and you will see how much more reliable the grid is then you think.
Jim Hunter
Friday, October 21, 2005
That's just a very simple sample to show the "leak".

destroy and create a new grid in some app is necessary.

AW's code need handle it<destroy and create grid again and again>, I think.
To Alex
Saturday, October 22, 2005
Yes, this is a bug. In 2.0b1 memory for AW objects is not released. I'll try to fix it for beta2.
Alex (ActiveWidgets)
Monday, October 24, 2005



This topic is archived.

Back to /general.faq.releases/

Documentation:

Forum search