Thanks Martin!

        That seems to have done it.

        Regards,
        Nate


On Mar 25, 2013, at 5:19 AM, Martin Wittemann wrote:

> Hey,
> after taking a quick look at your code, I did see that you are not properly 
> disposing the data array. The lines
>                               this._disposeArray("old");
>                               delete old;
>                               old = null;
> should all be replaced by a single
>                                old.dispose();
> which should be enough. If the data array is generated by a store, disposing 
> it should also dispose its children which is exactly what you need. After 
> that, your models should be clean. If there is still a memory leak, you 
> should find out what kind of objects are leaking by checking the object 
> registry (qx.core.ObjectRegistry).
> Regards,
> Martin
> 
> 
> Am 20.03.2013 um 04:27 schrieb Nathanial Byrnes <[email protected]>:
> 
>> Hello,
>>      I have a class (DataTable) that extends Window whose only widget is a 
>> table. DataTable has a property called data that is bound to a JSON data 
>> store. I have an interval timer set up that triggers a refresh of the data 
>> store. The property data has an apply function which sets the table's 
>> tablemodel data, which causes the table to display the newly fetched data. 
>> The problem I am having is that with a refresh rate of every few seconds, 
>> the browser memory consumption continually grows. This application is 
>> intended to be left running on status displays indefinitely. The code for my 
>> DataTable class is below. I am attempting some memory clean up (as you will 
>> see) which I am assuming is incorrect as it is not preventing the memory 
>> growth. I am hoping someone can point me in the correct direction to prevent 
>> the memory consumption I am seeing. I suspect that some data structures are 
>> still linked to DOM nodes and therefore preventing garbage collection, but 
>> am not well versed enough to dig into that theory...
>> 
>>      Thanks in Advance,
>>      Nate
>> 
>> qx.Class.define("edcwebapp.DataTable", 
>> {
>>      extend: edcwebapp.BaseWindow,
>>      properties: {
>>              winTitle: {
>>                      init: "Table Data"
>>              },
>>              columnHeaders: {
>>                      init: ["A", "B" ],
>>                      apply: "setColHeads"
>>              },
>>              dbSessionId: {
>>                      nullable: true,
>>                      init: null
>>              },
>>              pullUrl: {
>>                      init: "/get_data"
>>              },
>>              refreshDelay: {
>>                      nullable: false,
>>                      init: 5
>>              },
>>              data: {
>>                      nullable: true,
>>                      init: null,
>>                      apply: "applyData"
>>              },
>>              tableModel: {
>>                      nullable: true,
>>                      init: null
>>              },
>>              table: {
>>                      nullable: true,
>>                      init: null
>>              }
>>      },
>>      construct: function()
>>      {
>>              this.base(arguments);
>>              this.setCaption(this.getWinTitle());
>>              var layout = new qx.ui.layout.Grow();
>>              this.setLayout(layout);
>>              this.addListener("close", this.onClose, this);
>>              
>>              this.setTableModel(new qx.ui.table.model.Simple());
>>              var tmd = [ [ "please log in" ] ];
>>              this.getTableModel().setColumns( this.getColumnHeaders() );
>>              this.getTableModel().setData(tmd);
>>              
>>              this.setTable(new qx.ui.table.Table(this.getTableModel(), 
>> null));
>> 
>>              this.add(this.getTable());
>>              this.timer = qx.util.TimerManager.getInstance();
>>              this.timerId = null;
>>      },
>>      destruct: function() 
>>      {
>>              if ( this.timerId )
>>                      this.timer.stop(this.timerId);
>>      },
>>      members: {
>>              start: function() 
>>              {
>>                      if ( !this.getDbSessionId() )
>>                              return;
>>                      var url = this.getPullUrl() + "?edc_session_uuid=" + 
>> this.getDbSessionId() ;
>>                      this.data = new qx.data.store.Json();
>>                      this.data.bind("model", this, "data");
>>                      this.data.setUrl(url);
>>                      if ( this.getRefreshDelay() > 0 )
>>                              this.timerId = this.timer.start(this.refresh, 
>> this.getRefreshDelay() * 1000, this, null, 100);
>>              },
>>              refresh: function()
>>              {
>>                      this.data.reload();
>>              },
>>              applyData: function(value, old)
>>              {
>>                      if ( value )
>>                      {
>>                              var arr = value.toArray();
>>                              var ColHead = null;
>>                              // check if the middleware returned a header row
>>                              // if so we'll just create a new table later 
>> on...
>>                              if (arr[0].toArray()[0] == '__header__')
>>                              {
>>                                      var table = this.getTable();
>>                                      this.remove(table);
>>                                      var model = this.getTableModel();
>>                                      this.setTableModel(new 
>> qx.ui.table.model.Simple());
>>                                      var tmp = arr[0].toArray();
>>                                      tmp.shift();
>>                                      ColHead = tmp;
>>                                      arr.shift();
>> 
>>                                      this._disposeObjects("model");
>>                                      this._disposeObjects("table");
>>                                      delete model;
>>                                      delete table;
>>                              }
>> 
>>                              var arr2 = [ ];
>>                              console.log("copying array");
>>                              for ( var i = 0; i < arr.length; i++ )
>>                              {
>>                                      var row = arr[i].toArray();
>>                                      arr2[i] = row;
>>                              }
>> 
>>                              var oldData = this.getTableModel().getData();
>> 
>>                              if ( ColHead )
>>                              {
>>                                      this.setColumnHeaders(tmp);
>>                              }
>>                              this.getTableModel().setData(arr2);
>>                              if ( ColHead )
>>                              {
>>                                      this.setTable(new 
>> qx.ui.table.Table(this.getTableModel(), null));
>>                                      this.add(this.getTable());
>>                              }
>> 
>>                              this._disposeArray("oldData");
>>                              delete oldData;
>>                              this._disposeArray("value");
>>                              delete value;
>>                              value = null;
>>                              this.fireDataEvent("dataRefreshed", this);
>>                      }
>>                      if ( old )
>>                      {
>>                              this._disposeArray("old");
>>                              delete old;
>>                              old = null;
>>                      }
>>              },
>>              onClose: function()
>>              {
>>                      console.log("DataTable window closed");
>>                      if ( this.timerId )
>>                              this.timer.stop(this.timerId);
>>              },
>>              setColHeads: function(value, old)
>>              {
>>                      if (value)
>>                      {
>>                              console.log("setColumns called");
>>                              var tmd = this.getTableModel();
>>                              if ( tmd )
>>                              {
>>                                      console.log("setColumns called with 
>> model");
>>                                      //var idx = [];
>>                                      //for ( var i = 0; i < value.length; 
>> i++ )
>>                                      //      idx.push(i);
>>                              //      tmd.setColumns(value, idx);
>>                                      tmd.setColumns(value);
>> 
>>                                      //for ( i = 0; i < value.length; i++ )
>>                                      //      
>> this.getTable().getTableColumnModel().setColumnVisible(i, true);
>>                              }
>>                      }
>>              }
>> 
>>      },
>>      events: {
>>              "dataRefreshed": "qx.event.type.Data"
>>      }
>> });
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_mar
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to