United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7143857 Memory leak in javax.swing.plaf.synth.SynthTreeUI
JDK-7143857 : Memory leak in javax.swing.plaf.synth.SynthTreeUI

Details
Type:
Bug
Submit Date:
2012-02-08
Status:
Closed
Updated Date:
2012-06-06
Project Name:
JDK
Resolved Date:
2012-03-07
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u4
Fixed Versions:
7u4 (b13)

Related Reports
Backport:

Sub Tasks

Description
J2SE Version (please include all output from java -version flag):
 JDK 6 and 7


Does this problem occur on J2SE 1.5 or 6ux?  Yes / No (pick one)
 N/A


Bug Description:

had experiencing memory problems with our swing base client app. 
Digging into the problem and found the root cause in 
"javax.swing.plaf.synth.SynthTreeUI". 

Checked the preview releases of jdk6 and 7 which both still 
contain the issue. Hope to adress this problem so that a fix 
would be encorporated in one of the next official release?

If it helps here is a short explaination of the problem and a possible fix:

1) Class "javax.swing.plaf.synth.SynthTreeUI" has a field named 
   "paintContext" of type "javax.swing.plaf.synth.SynthContext"

2) The field is set in the first line  of method 
   "protected void paint(SynthContext context, Graphics g)"

3) The field is never cleared

4) According to our memory analyzer tool the instance keeps 
   references to dialog instances, event if this dialog instances 
   have been disposed and are otherwise not reachable

5) According "javax.swing.plaf.synth.SynthContext" instances 
   should not be cached (from java doc: "A SynthContext should 
   only be considered valid for the duration of the method it is 
   passed to. In other words you should not cache a SynthContext 
   that is passed to you and expect it to remain valid.")


Fix: Null the reference at the end of the 
     "paint(SynthContext context, Graphics g)" 
     (there is alread a comment about "gc"):

        // Empty out the renderer pane, allowing renderers to be gc'ed.
        rendererPane.removeAll();
        paintContext = null; // <---------------- add this line

                                    

Comments
EVALUATION

See main CR evaluation
                                     
2012-02-16



Hardware and Software, Engineered to Work Together