Any widget that is added to the DOM seems to never get garbage collected 
when using dev mode, even if it's removed from the DOM. Here is the sample 
source, with just two classes:

public class GwtMemEntryPoint implements EntryPoint {

    @Override
    public void onModuleLoad() {
for (int i = 0; i < 3; i++) {
    RootLayoutPanel.get().clear();
    RootLayoutPanel.get().add(new LeakyWidget());
}
    }

}

public final class LeakyWidget extends Label {

    private static int count = 0;

    public LeakyWidget() {
setText("Hello Leaky Widget " + (++count));
    }

}

*Configuration*
- OS/X 10.9.1
- Eclipse Kepler SR1
- Eclipse Memory Analyzer Tool 1.3.1
- GWT 2.5.1
- Firefox 26.0
- JDK 1.7.0_51

*To reproduce*
- Run the above application
- Run GC manually (I used jconsole for this)
- Run Eclipse Memory Analyzer to get a heap dump 
(http://www.eclipse.org/mat/)
- View the number of instances of LeakyWidget in the heap dump

*What I'd expect*
- The number of instances of LeakyWidget to be 1, which is the only widget 
that hasn't yet been removed from the DOM, the one currently displayed

*What actually happens*
- The number of instances of LeakyWidget is still 3. If you keep reloading 
the sample, the number of widgets keeps increasing. They are released when 
you quit Firefox.

*Question*
So why is this the case, and is it by design? I would like a way to look 
for memory leaks in my code in dev mode without compiling to JS and using a 
JS debugger, but if this is not possible, and if this leak is by design, it 
would be good to know.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to