United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6468338 Memory leak in XPStyle
JDK-6468338 : Memory leak in XPStyle

Details
Type:
Bug
Submit Date:
2006-09-07
Status:
Closed
Updated Date:
2011-03-09
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
XPStyle keeps around a map that can include references to components. This is bad in that as XPStyle never goes away, the components can never be gc'd. Here's the reference list:

--> class com.sun.java.swing.plaf.windows.XPStyle (84 bytes) (static field xp:)
--> com.sun.java.swing.plaf.windows.XPStyle@0x19332e00 (17 bytes) (field borderMap:)
--> java.util.HashMap@0x19336860 (40 bytes) (field table:)
--> [Ljava.util.HashMap$Entry;@0x193bd538 (72 bytes) (Element 10 of [Ljava.util.HashMap$Entry;@0x193bd538:)
--> java.util.HashMap$Entry@0x194cbdc8 (24 bytes) (field key:)
--> com.sun.java.swing.plaf.windows.XPStyle$Skin@0x194d0020 (28 bytes) (field component:)
--> javax.swing.JToolBar@0x18ed27c8 (330 bytes) (field parent:)
--> javax.swing.JPanel@0x18ed25a8 (320 bytes) (field parent:)

                                    

Comments
EVALUATION

XPStyle has a map HashMap<Skin, Border> borderMap. Skin has a field
Component. This map is never cleaned. Thus there is reported memory
leak.

Skin is used for very short period of time. It should be created only
when needed and discarded as soon as we done with it. Only one field
from Skin is used to hashCode() and equals(). This field is Skin.string.

I suggest to change borderMap to HashMap<String, Border> and use
skin.string as a key instead of the skin.
                                     
2006-09-07
EVALUATION

I don't think this is a showstopper, so I'm moving it to update 1.
                                     
2006-10-12
EVALUATION

this bug is a regression introduced by the fix for 6236482 [Win L&F: Use enums instead of strings in XPStyle]
                                     
2006-12-18



Hardware and Software, Engineered to Work Together