<AWT Dev> Standalone test was: Memory leaks due to static references in AWT & Swing

Jaroslav Tulach jtulach at netbeans.org
Thu Jul 21 05:11:52 PDT 2011


>## 21. 7. 2011 12:12:13 ##<
> Nice.
> 
> However, this confirms my concern. When a showing dialog is going out of
> scope, without having dispose() or such called before, what is supposed
> to happen? 

Actually the test calls dispose():
  d.setVisible(visibility);
  if (!visibility) {
    d.dispose();
  }
so in this case the answer is easy, the dialog should be eligible for GC.

> AWT resource management is not 100% automatic AFAIK.

I am ready to help the system. Just using reflection to clean some fields 
seems like a too dirty kind of help...
-jt


> Am Donnerstag, den 21.07.2011, 12:04 +0200 schrieb Jaroslav Tulach:
> > >## 20. 7. 2011 12:32:02 ##<
> > >
> > > >## 20. 7. 2011 10:04:26 ##<
> > > >
> > > > But do you have test which can prove that any of these fields cause
> > > > real memory leak?
> > > 
> > > Yes, I have a test. My whole motivation is to fix our tests. Here is
> > > one of them:
> > > http://hg.netbeans.org/ergonomics/file/f6cc96cf2c44/core.windows/test/u
> > > nit/ src/org/netbeans/core/windows/services/NbPresenterLeakTest.java
> > 
> > I've modified the above test to be standalone (see attachement). It fails
> > in about 50% of cases
> > 
> > ---
> > Exception in thread "main" java.lang.AssertionError: Dialog disappears.
> > 
> >   org.netbeans.core.windows.services.NbPresenterLeakTest.assertGC(NbPrese
> >   nterLeakTest.java:181)
> >   org.netbeans.core.windows.services.NbPresenterLeakTest.main(NbPresente
> >   rLeakTest.java:100)
> > 
> > ---
> > 
> > on my computer. I am running Kubuntu 11.04 and using:
> > 
> > ---
> > $ java -version
> > java version "1.6.0_26"
> > Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
> > Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
> > ---
> > 
> > Can we proceed with evaluation of my patch now?
> > -jt



More information about the awt-dev mailing list