JDK-6468338 : Memory leak in XPStyle
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-07
  • Updated: 2013-11-01
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u1Fixed 7 b07Fixed
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 this bug is a regression introduced by the fix for 6236482 [Win L&F: Use enums instead of strings in XPStyle]
18-12-2006

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

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.
07-09-2006