Hello,
we develop large application where is used TabLayoutPanel very often -
everything is opened in tab.
I noticed that in IE (8,9) is consuming of memory very big and IE
slows down. If I watch using memory of IE in task manager I noticed
that every opened tab consumed memory but after closing tab - no
memory is released.
I tried to search where is problem. I wrote this small program which
should test releasing memory after closing tab:

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;


public class Tester implements EntryPoint {

        //Simple label with huge consuming of memoty
        private static class TestLabel extends Label {
                int MAX = 10000000;
                private int[] empty = new int[MAX];
                public TestLabel() {
                        super("test");
                        for (int cnt=0;cnt<MAX;cnt++){
                                empty[cnt]=0;
                        }
                }
        }

        public void onModuleLoad() {
                final FlowPanel fp = new FlowPanel();
                testLeak(fp);

                RootLayoutPanel.get().add(fp);
        }

        private void testLeak(final FlowPanel fp) {
                final TabLayoutPanel tp = new TabLayoutPanel(30, Unit.PX);
                //final FlowPanel tp = new FlowPanel();
                tp.setSize("800px", "400px");
                fp.add(tp);

               //button for performin garbage collection
                Button b = new Button("Garbage collector");
                fp.add(b);
                b.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                runGarbage();
                        }
                });

                //button for remove first component
                Button deleteButton = new Button("delete tab");
                fp.add(deleteButton);
                deleteButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                tp.remove(0);
                        }
                });

                //add widget
                Button widgetB = new Button("Add widget");
                fp.add(widgetB);
                widgetB.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                                tp.add(new TestLabel());
                        }
                });
        }

        public native static void runGarbage()
        /*-{
                $wnd.CollectGarbage();
        }-*/;
}


I created TestLabel widget which is simple Label but which allocated
some memory, to be able to notice creating widget in taskmanager. I
created several  tabs with this memory-consuming-widget, after i
removed from tabLayoutPanel every added tab a I didn't noticed any
releasing of memory. When I run garbage collector manually by method
runGarbage() nothing happed. When I replace TabLayoutPanel with
FlowPanel releasing memory is OK.
Is this memory leak? Do you have similar experience?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to