<AWT Dev> Memory leaks due to static references in AWT & Swing
son.two at gmail.com
Wed Jul 20 01:04:26 PDT 2011
as far as I can see you suggest to replace strong references to
focusOwner, permanentFocusOwner, focusedWindow, and activeWindow to
But do you have test which can prove that any of these fields cause
real memory leak?
As far as I know KFM is supposed to update these fields as soon as
focus state has been changed, thus if
you do have memory leak then it is a bug in KFM and your fix is just a
workaround for the problem.
On Wed, Jul 20, 2011 at 11:36 AM, Jaroslav Tulach <jtulach at netbeans.org> wrote:
> 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
> 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
> 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.
More information about the awt-dev