Hello all,

I am having some serious problems with a big application that is using
a lot of the browser's memory (Internet Explorer 6 and 7).
It is a single page that constantly
removes/adds widgets to panels, so it doesn't navigate to external
links. It uses a 3rd party lib: gwt-ext, so this is my primary
suspect.

However, I analyzed the application with sIEve
(http://home.wanadoo.nl/jsrosman/), and I think that removing and
adding widgets dinamycally to panels could be one cause of my
problems.

I created the following test:


package testgroup.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class Application implements EntryPoint {

    private boolean added = false;
    private Widget  mywidget = null;
    private int     counter = 0;

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {


        final Panel mypanel = new SimplePanel();
        final Button mybutton = new Button("Add or remove label");

        mybutton.addClickListener(new ClickListener() {
            public void onClick(Widget arg0) {
                if (added) {
                    mypanel.remove(mywidget);
                    mywidget = null; // just in case
                } else {
                    mywidget = new Label("this is a new label "+
(counter++));
                    mypanel.add(mywidget);
                }
                added = !added;
            }
        });

        RootPanel.get().add(new Label("Leak example"));
        RootPanel.get().add(mybutton);
        RootPanel.get().add(mypanel);
    }
}


When testing with sIEve, it says that this generates 38 DOM nodes and
~7512 kb of memory. Every time I click the button in order to add a
label to the panel, a new DOM node is created and the memory increases
by some kb (sometimes 4kb, 20kb, I don't see a pattern). But when I
click again
to remove it, neither the number of DOM nodes decreases nor the
memory.

What is going on here?

I also tested with a timer:

        Timer timer = new Timer() {
            public void run() {
                if (added) {
                    mypanel.remove(mywidget);
                    mywidget = null; // just in case
                } else {
                    mywidget = new Label("this is a new label "+
(counter++));
                    mypanel.add(mywidget);
                }
                added = !added;
            }
        };
        timer.scheduleRepeating(500);

But in this case, the DOM and memory are stable!
I am really confused here, this is obviously not my application, but
my application does a lot of add/remove of much more complicated
widgets that consume some space.

I am using GWT-1.4.61, but the same behaviour is happening with 1.5.2.

Please, does anyone have any ideas on this?

Thanks

David

--~--~---------~--~----~------------~-------~--~----~
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