JDK-4228292 : MEMORY LEAK OF LIGHTWEIGHTDISPATCHERS OCCURRING IN JAVA.AWT.CONTAINER
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-04-09
  • Updated: 1999-04-09
  • Resolved: 1999-04-09
Related Reports
Duplicate :  
Description

Name: clC74495			Date: 04/09/99


This bug report is from Oracle, a Java licensee. 
It occurs in JDK1.1.7B.  The Oracle bug number is 868559. 

While looking for memory leaks, we found some "LightweightDispatcher"
objects were leaking. LightweightDispatcher is defined in
java/awt/Container.java. We found that in trackMouseEnterExit the method
startListeningForOtherDrags is called. This does a
Toolkit.getEventQueue().addEventQueueListener(this). The method
stopListeningForOtherDrags (which does the corresponding removeListener)
is only called if trackMouseEnterExit gets a MOUSE_EXITED event. It looks
like sometimes that never happens, and so the LightweightDispatcher, as long
and any objects it refers to, will never get GC'ed. This seems to happen
a lot if you wiggle the mouse over a window when it's disappearing.

The following code fixes the problem:

[in LightweightDispatcher.removeNotify(), just before "super.removeNotify();"]
    if (dispatcher != null ) {
        Toolkit.getEventQueue().removeEventQueueListener(dispatcher);
        dispatcher = null;
    }
[end]

An alternative is to remove the "private" from the definition of
stopListeningForOtherDrags, and to call that instead of calling
removeEventQueueListener directly.
(Review ID: 56783)
======================================================================