Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4496253
Votes 7
Synopsis Memory leak Container.java removeNotify LigthweightDispatcher
Category java:classes_awt
Reported Against merlin-beta
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 24-AUG-2001
Description




java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

This appears to be the same issue as #4228292 only it must have moved into
Container.java proper.

This APPEARS to also be in Java 1.4beta as the Container.java source is
unchanged -- but I haven't begun testing under 1.4beta.

We're using a single JVM to launch multiple applications using Method.invoke on
main() for our individual applications.  We've gone to great lengths to insure
memory is collected, and cleaned up if an application closes.

Using OptimizeIt we've manage to clear every reference in our applications,
with the exception of one that is being held by Container.java -- a
LightweightDispatcher.  We modified Container.java to set dispatcher = null
after calling dispatcher.dispose() in removeNotify().  This allows us to have
no memory leaks.

We'd like to NOT have to patch Container.java ourselves.
(Review ID: 130645) 
======================================================================
Work Around




Add specified line setting dispatcher=null; to Container.java and replace in
rt.jar -- ugly, but doable.

/**
* Makes this Container undisplayable by removing its connection
* to its native screen resource.  Make a container undisplayable
* will cause any of its children to be made undisplayable.
* This method is called by the toolkit internally and should
* not be called directly by programs.
* @see Component#isDisplayable
* @see #addNotify
*/
public void removeNotify()
{
	synchronized(getTreeLock())
	{
		int ncomponents = this.ncomponents;
		Component component[] = this.component;
		for (int i = 0 ; i < ncomponents ; i++)
		{
			component[i].removeNotify();
		}
		if (dispatcher != null)
		{
			dispatcher.dispose();
			dispatcher = null;	// *** FIX: ADD this line! ***
		}
		super.removeNotify();
	}
}
======================================================================
Evaluation
Commit to fix in Tiger (memory leak).  
 xxxxx@xxxxx  2002-08-21

This such a quick fix that I'm putting it back into Mantis.
 xxxxx@xxxxx  2002-09-10
Comments
  
  Include a link with my name & email   

Submitted On 20-AUG-2002
rconner
Hmm?  Been nearly a year and no progress on a ONE LINE fix?
No evaluation even?
We're still having to "patch" rt.jar.
Surely SOMEBODY can add one line.



PLEASE NOTE: JDK6 is formerly known as Project Mustang