<AWT Dev> Memory leaks due to static references in AWT & Swing

Jaroslav Tulach jtulach at netbeans.org
Wed Jul 20 00:36:13 PDT 2011


Hello.
My name is Jaroslav Tulach and I working on NetBeans. Recently I started to 
fight with memory leaks by writing some automated tests to verify that some 
sequence of actions does not leave a memory behind.

I think the tests are paying off, we managed to fix many leaks in NetBeans 
code. However now we are facing an unsolvable problem: there are some 
(temporary) leaks in AWT and Swing code which cause our tests to randomly 
fail.

We tried to workaround the problem (by opening new unrelated windows, or using 
reflection to clean well known references), but so far our solutions are 
fragile and the test continue to fail in new, inventive ways (for example 
https://netbeans.org/bugzilla/show_bug.cgi?id=197905).

It would be much easier if we could eliminate the (temporary) memory leaks in 
AWT/Swing code. I am attaching a patch that uses WeakReference instead of 
strong one that would fix one of our failing test.

What it would take to accept my patch? Thanks for your advice and help.
-jt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: no-leaks-from-KeyboardFocusManager.diff
Type: text/x-patch
Size: 7295 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20110720/09ae5f66/no-leaks-from-KeyboardFocusManager.diff 


More information about the awt-dev mailing list