View Full Version : [FIXED] memory leak in combobox?

6 Aug 2008, 1:19 AM

we are experiencing that the browser (IE6, IE7 and Firefox) uses more and more memory in our application. We are using input forms a lot and traced back the problem to the usage of the ComboBox widget.

I wrote a little demo for the problem that interactively allows to
- add 50 Html widgets to a container
- add 50 Comboboxes to a container
- remove all widgets from the container

I tried to follow the memory consumption in window's taskmanager when doing the following actions:
1. add 50 Html Widgets (multiple times if you want)
2. clear
3. note the memory size of iexplorer (the first clear results in less memory than on startup of the application, no idea why)
4. add 50 html widgets (multiple times if you want)
5. clear
6. the memory is about the same as in step 3
7. add 50 comboboxes
8. clear
9. the memory did not go down on clearing the comboboxes and shows the same result as after step 7

I tried to do the same with IESieve, but there neither memory nor dom objects go down ever. So I am not sure if there is a problem with IESieve or my code :-)

The code to test:

package testmemoryleak.client;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

* Entry point classes define <code>onModuleLoad()</code>.
public class ComboboxMemoryleak implements EntryPoint {

public static final int WIDGET_COUNT = 50;
LayoutContainer container;

public void onModuleLoad() {
Viewport viewport = new Viewport();

LayoutContainer buttonContainer = new LayoutContainer();
container = new LayoutContainer();

Button clearButton = new Button("clear", new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
Button addBadButton = new Button("add widgets with memory leak", new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
long start = System.currentTimeMillis();
for (int index = 0; index < WIDGET_COUNT; ++index) {

Button addGoodButton = new Button("add 'good' widgets", new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
for (int index = 0; index < WIDGET_COUNT; ++index) {

container.setLayout(new TableLayout(5));


* Creates and returns a widget without memory leak.
public Widget createWidgetNormal(int index) {
return new Html("widget " + index);

* Creates and returns a widget that has a memory leak (memory in browser will not be freed
* after removal of this widget).
public Widget createWidgetMemLeak(int index) {
ComboBox<BaseModel> box = new ComboBox<BaseModel>();
box.setId("id" + index);
ListStore<BaseModel> store = new ListStore<BaseModel>();
for (int modelIndex = 0 ; modelIndex < 7; ++modelIndex) {
BaseModel data = new BaseModel();
data.set("id", modelIndex);
data.set("index", modelIndex);
data.set("label", "key" + modelIndex);
data.set("value", "value" + modelIndex);

return box;
Versions used (server on linux, browser on windows)
Browser: IE6, IE7, Firefox 3 on windows XP
GXT: 1.0.1 and 1.0.2
GWT: 1.5-RC1 (linux)

6 Aug 2008, 1:31 AM
may not solve the problem, but GWT 1.5.1 (RC2) has some memory leak fixes that seems to work with GXT - limitted testing on my part.... give that a try and see if this changes the outcomes ???

6 Aug 2008, 1:35 AM
thanks for the info, I'll give it a try...

6 Aug 2008, 2:49 AM
No GWT-1.5.1 does not make any difference. Did some more tests with firefox, and it seems that firefox does not release any memory at all. Very strange!

After some more tests:
No difference between gwt-1.5.0-RC1 and gwt-1.5.1 (RC2): IE6 frees some memory (for Html widget), firefox does not free any memory (on Html or ComboBox widget).

Please, could someone explain how to minimize memory consumption in browsers? What is wrong in "removeAll"?


26 Aug 2008, 10:13 AM
Is there anybody out there to confirm this behavior? The browser's memory footprint grows and grows. This is a blocker for us!

We did some more experiments with firefox (linux, windows), IE6 on windows XP.

We tried to build more or less the same example with pure gwt (no gxt): Windows Taskmanager shows that the memory does not grow (when adding/removing gwt widgets), while drip (ieleak) shows a steady increase of memory.

Firefox (windows XP (measured with Taskmanager) and linux) does not return any memory at all.

I really cannot believe that gwt and/or gxt just consumes memory and never returns it again! Is this a browser problem, a measurement problem?

We were close to buy some gxt licenses, but this problem needs to be solved first.

27 Aug 2008, 7:58 AM
The issue is confirmed and the fix will go in the next release.

27 Aug 2008, 8:01 AM
The issue is confirmed and the fix will go in the next release.

Cool! When will be the next release?


27 Aug 2008, 8:04 AM
1.0.3 will go in a day or two.

27 Aug 2008, 8:58 AM
Fix is in SVN. Also, with the new code you can do combo.setLazyRender(true) and the drop down list will not be rendered until it is first displayed.

27 Aug 2008, 10:40 PM
Fix is in SVN. Also, with the new code you can do combo.setLazyRender(true) and the drop down list will not be rendered until it is first displayed.

sounds great! Looking forward to the new release!

10 Sep 2008, 2:11 PM
Will this fix go into ExtJS as well? I have the same memory usage problem where I create a lot of tabs with FormPanels, but when I close the tabs, the memory doesn't go back down. It looks like destroy() may not be cleaning up everything nicely?

11 Sep 2008, 5:41 AM
The problem in Ext GWT is unrelated to the code in Ext JS. If you are having an issue, you will need to post in the JS forums.