Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 394643

Summary: [Tree][Table][Grid] Memory leak in Grid on client
Product: [RT] RAP Reporter: Tim Buschtoens <tbuschto>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: ivan, rsternberg, tbuschto
Version: 1.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: sr152
Attachments:
Description Flags
patch for 1.5 tbuschto: review?

Description Tim Buschtoens CLA 2012-11-20 07:17:55 EST
There is a memory leak in the Grid (Tree/Table) implementation! I noticed this while looking into Bug 373357. When disposing an entire Tree/Table, the single items are not disposed. In the LCA's for the items the renderDispose looks like this:

  public void renderDispose( Widget widget ) throws IOException {
    TableItem item = ( TableItem )widget;
    if( !isParentDisposed( item ) ) {
      // The tree disposes the items itself on the client (faster)
      ClientObjectFactory.getClientObject( widget ).destroy();
    }
  }

The comment is not true, at least not since the protocol switch. This means that since 1.5, Trees and Tables are not disposed correctly and cause the browser to permanently grow in memory usage. 

Disposing items directly should be ok for Table, for Tree we probably have the same issue with parent items.
Comment 1 Tim Buschtoens CLA 2012-11-20 10:06:36 EST
For 2.0 this should be fixed with Bug 373357. For 1.5 i would not introduce such big changes and just fix the LCAs like this:

  public void renderDispose( Widget widget ) throws IOException {
    TableItem item = ( TableItem )widget;
    ClientObjectFactory.getClientObject( widget ).destroy();
  }

If no one objects to that idea i will provide such a patch for 1.5 soon.
Comment 2 Tim Buschtoens CLA 2012-11-21 07:54:54 EST
Created attachment 223800 [details]
patch for 1.5

Fixes the issue for 1.5 as uninvasive as possible.
Comment 3 Tim Buschtoens CLA 2012-11-21 12:00:12 EST
Fixed with commit 52d60d1743aa4bc315416f9cf7608e97e11244b6 in master. Items are destroyed on the client.
Comment 4 Ivan Furnadjiev CLA 2012-11-27 11:55:06 EST
(In reply to comment #2)
> Created attachment 223800 [details]
> patch for 1.5
> 
> Fixes the issue for 1.5 as uninvasive as possible.
Tim, I prefer client solution like in 2.0. In case of a big Tree/Table we will render very big JSON message from the server (a lot of destroy operations).
Comment 5 Ivan Furnadjiev CLA 2013-01-24 05:01:41 EST
I did some testing today in IE9 and Chrome with Controls Demo -> Table Tab (non virtual Table with 100 items). 
After creation and disposal of the Table 100 times the memory increase is:
- Chrome - 14M
- IE9 - 30MB
There is no big difference between the times needed for disposal only of Table or Table + all (100) TableItems:
- Chrome - 40ms / 45ms
- IE - 20ms / 25ms
That's why I think that the proposed fix in comment#2 is fine for 1.5-maintenance branch.
Comment 6 Ralf Sternberg CLA 2013-01-24 05:30:46 EST
I agree. +1 for Tim's patch.
Comment 7 Ivan Furnadjiev CLA 2013-01-24 10:54:53 EST
Applied the patch from comment#2 to 1.5-maintenance branch with commit 83e2b9bdecc4f0b2fe8df4bbca6c6cdeaecd5ee7.