PDA

View Full Version : Psudo Memory Leak



splilly
3 Mar 2009, 10:52 AM
Hi. I have an issue where the memory usage of the browser continues to grow throughout the running of my gwt / gxt application. It would appear that some memory is lost / leaked due to the use of gxt. Using only gwt based widgets does not cause the memory leak. As a simple test case I tried rapidly creating and removing a gxt "ContentPanel" and you can watch the browser memory increase. My sample is so simple that I can't see how it could be anything I am doing wrong so I'm assuming it is a bug in gxt.

My sample is composed of 3 java files. I'll post them here for others to verify.

GWT 1.5.3
GXT 1.2.3
IE6

splilly
3 Mar 2009, 10:55 AM
package net.example.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MemTest implements EntryPoint {
private VerticalPanel mainPanel;

public void onModuleLoad() {
mainPanel = new VerticalPanel();

final Timer replaceSampleWidget = new Timer() {
@Override
public void run() {
if (mainPanel.getWidgetCount() > 3) {
mainPanel.remove(3);
}
SampleWidget innerPanel = new SampleWidget();
mainPanel.add(innerPanel);
}
};

final Timer replaceSampleWidgetWithGxt = new Timer() {
@Override
public void run() {
if (mainPanel.getWidgetCount() > 3) {
mainPanel.remove(3);
}
SampleWidgetWithGxt innerPanel = new SampleWidgetWithGxt();
mainPanel.add(innerPanel);
}
};

Button start = new Button("Start without Gxt", new ClickListener() {
public void onClick(Widget arg0) {
replaceSampleWidget.scheduleRepeating(50);
}
});

Button startWithGxt = new Button("Start with Gxt", new ClickListener() {
public void onClick(Widget arg0) {
replaceSampleWidgetWithGxt.scheduleRepeating(50);
}
});

Button stop = new Button("Stop", new ClickListener() {
public void onClick(Widget arg0) {
replaceSampleWidget.cancel();
replaceSampleWidgetWithGxt.cancel();
}
});
mainPanel.add(start);
mainPanel.add(startWithGxt);
mainPanel.add(stop);
RootPanel.get().add(mainPanel);
}
}

splilly
3 Mar 2009, 10:56 AM
package net.example.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class SampleWidget extends Composite {
private static int count = 0;
private VerticalPanel content;

public SampleWidget() {
content = new VerticalPanel();
content.add(new Label("Testing " + count++));
initWidget(content);
}
}

splilly
3 Mar 2009, 10:57 AM
package net.example.client;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class SampleWidgetWithGxt extends Composite {
private static int count = 0;
private VerticalPanel content;

public SampleWidgetWithGxt() {
content = new VerticalPanel();
content.add(new Label("Testing " + count++));
content.add(createGxt());
initWidget(content);
}

public Widget createGxt() {
ContentPanel panel = new ContentPanel();
panel.setFrame(true);
return panel;
}
}

sbarkdull
9 Oct 2009, 5:54 AM
I have an application that uses a content panel and 2 grid controls. The grids are refreshed every 30 seconds with new data from the server. On every grid refresh, the memory consumption increases, and never decreases.

My current theory is that there is a memory leak in the grid's store's loader.

This is making my application unusable after about 30-60 minutes of operation.

This problem is a total show stopper for my app (which is in production).

This problem shows on all browsers I've tested with (FFox, Safari, IE, Chrome).

Google claims the GWT is memory - leak - proof, so I am focusing my attention on the possibility that the problem is in GXT.

Does anyone know of any good tools for debugging javascript memory leaks in the browser?

sven
9 Oct 2009, 7:36 AM
You should try to reproduce the grid issue in a minimal example. I dont see this.

ALso i cant reproduce the issue from the first posts anymore with gwt 1.2 from SVN

sbarkdull
9 Oct 2009, 1:50 PM
I am hoping that moving to the newer versions (GWT 1.7 and GXT 2.0) of the 2 toolkits/frameworks will resolve some of the leaks I am seeing.

If not, I'll develop a minimal example to try to demo the problem.

Baus
21 Oct 2009, 12:59 AM
Hi,
we have created a enterprise application with GWT-Ext.
This problem makes us very worried at the time (After 30 min., We have 1.6 GB in memory. (Task Mananger)).

We are considering to switch to GXT.
But this is a problem if GXT has the same problem.

My question is, how GXT deal with the problem?

THX
Johann

sven
21 Oct 2009, 3:46 AM
GXT2, which i suggest you should use, has no known memoryleaks. Also the last development version of GXT 1.2 doesnt has a known one.

sbarkdull
21 Oct 2009, 5:04 AM
I just located and reported a memory leak in GXT 2.0 in the GridView's refresher (GridView.refresh()). One of EXT JS's engineers confirmed the memory leak, and had a fix ready to be checked in as of some time last week.

The engineer said: "This was already reported before and i have the fix already ready. It will be in SVN today and will be part of GXT 2.0.3 ", I believe his name was Sven.

Based on my application's memory usage patterns, I am concerned that there may be a memory leak in the GridView's loader.

sven
21 Oct 2009, 5:12 AM
Yes there was one whhen using the widgetrendering. I fixed that one.

We discovered that one a bit earlier already when we did some big memory usage tests.

sven
21 Oct 2009, 5:17 AM
Based on my application's memory usage patterns, I am concerned that there may be a memory leak in the GridView's loader.

Are you using local data or are you loading the data for example with HttpProxy or RpcProxy? If so than you probably want to look into this GWT bug report http://code.google.com/p/google-web-toolkit/issues/detail?id=4133&q=XMLHttpRequest