Hi Philipp,

see inline comments below.

Am 20.02.2007 um 17:21 schrieb Philipp Wabinski:

>> On 2/18/07, Andreas Junghans <[EMAIL PROTECTED]> wrote:
>>>
>>> I suppose your problem is that with each data-reload, you're  
>>> creating
>>> new qooxdoo objects but never call dispose() on them? By default,
>>> every qooxdoo object is registered in a global object db, and if you
>>> don't call dispose() on the object if you no longer need it, this
>>> reference is held forever.
>>>
>>
>
> Hi Andreas,
>
> I dont think that I create new objects on the reload of table data. I
> something like the following:
>
> I add a table Model with some columns
>
>> this.tableModel = new flare.ui.table.SimpleTableModel();
>> this.tableModel.setColumns(["x","y","z"]);
>
> Then I create a table:
>
>> this.table = new qx.ui.table.Table(this.tableModel);
>
> with (this.table) {
>           // set column renderer, widths etc.
>       }
>
> I add this Table to my layout and have a button that calls the  
> following
> function to load the data of the table from the database.
>
> qx.Proto.updateTable = function(updateObject, selectedKstString)
> {
>      var rpc = new qx.io.remote.Rpc();

This is a problem (you create a new Rpc object everytime, but you  
never dispose it). Why do you create this on every data update? It  
would be easier to just create it once and then reuse it for  
subsequent calls.

>      rpc.setTimeout(120000);
>      var mycall = null;
>
>      rpc.setUrl(CONFIG["jsonRpcPath"]);
>      rpc.setServiceName("SERVICE");
>      rpc.setCrossDomain(true);
>
>      mycall = rpc.callAsync(function(result, ex, id) {
>         mycall = null;
>       if (ex == null && result != null)
>       {
>             _this.tableData = [];
>             for(i = 0; i < result.length; i++)
>           {
>                 if(result[i][6])
>               {
>                   result[i][6] = new
> qx.util.format.DateFormat('yyyy-MM-dd').parse(result[i][6]);

This is the next problem. Again, you're creating a new object  
(DateFormat), but you never dispose it. Like with the Rpc, it would  
be better to create this once (since you're always using the same  
date format) and reuse the instance.

> That is infact what I am doing. The only objects I create are the  
> DateFormat
> objects and some additional stuff.

See above. The leaks I could immediately identify are Rpc and  
DateFormat. They may look small, but if you have a new DateFormat for  
each row, it adds up. There are also a lot of sub-objects used  
internally by the Rpc, so you end up with even more stuff that never  
gets freed.

> I tried to dispose this.table or this.tableModel bevor I updated  
> the data
> but that doesnt work at all. I get some errors on loading the table  
> or the
> memory usage is already increasing.

If you're just changing data, there's no need (and it's in fact  
wrong, as you found out) to dispose the table or the model.

> Do I have to call a function to iterate throug this.tableData an
> dispose every object inside bevor I add new data?

No, since the data (usually) consists only of native JavaScript types  
(string, number) and not qooxdoo objects.

> Do I have to dispose every
> object I create in the updateTable  function?

Yes, see above. But if you create the Rpc object and DateFormat only  
once, qooxdoo takes care of disposing them on page unload (so there's  
nothing you have to do manually).

We might be able to change some framework classes that don't have DOM  
dependencies (e.g. DateFormat) so that they're not registered in the  
object DB. However, this would make things inconsistent: You would  
have to dispose some objects, but not all. Of course, it's quite ugly  
that you have to dispose temporary objects manually in the first  
place, but it's currently the only way to deal with known browser  
leaks. If there were no leaks in browsers (and hopefully some day  
that will be the case), all the dispose stuff would become moot, and  
you could simply rely on the automatic garbage collection.

Regards,

   Andreas


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to