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

Roman Kennke roman at kennke.org
Wed Jul 20 01:43:24 PDT 2011

Hi Oleg,

> as far as I can see you suggest to replace strong references to
> focusOwner, permanentFocusOwner, focusedWindow, and activeWindow to
> weak ones.
> 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.

That is a reasonable concern.

What I know is that in one of the projects at my workplace we *are*
having problems with the KFM keeping the permenentFocusOwner even though
it should be GCed. I have no testcase though.

The permanentFocusOwner seems to be reset only from removeNotify(), so I
guess the question is, could a component hierarchy go out of scope (in a
valid way) without having removeNotify() being called?

On the other hand, I would still like to understand why are those fields
static? Shouldn't they be instance in the KFM?

Regards, Roman

More information about the awt-dev mailing list