<Swing Dev> [12] RFR JDK-8204963:javax.swing.border.TitledBorder has a memory leak

Krishna Addepalli krishna.addepalli at oracle.com
Mon Aug 6 14:57:35 UTC 2018


Hi Prasanta,

Could you explain the fix a bit more. AFAIK, the earlier code should also not hold the reference to TitledBorder, longer than necessary.
Whether an anonymous class, or a static named class, the UI manager would maintain a strong reference to PropertyChangeListener/TitledBorderPropertyChangeListener, which inturn maintains a WeakReference to TitledBorder.

Thanks,
Krishna

-----Original Message-----
From: Prasanta Sadhukhan 
Sent: Monday, August 6, 2018 8:11 PM
To: swing-dev at openjdk.java.net
Subject: <Swing Dev> [12] RFR JDK-8204963:javax.swing.border.TitledBorder has a memory leak

Hi All,

Please review a memory leak issue in javax.swing.border.TitledBorder where it is seen that TitledBorder instances are never freed. This leak is an aftereffect of JDK-8152159.
This is because
javax.swing.border.TitledBorder.installPropertyChangeListeners() creates an instance of an anonymous inner class that implicitly holds a reference to the containing TitledBorder class.
Proposed fix is to make it a named static class so that it does not hold reference and can be garbage collected.

Bug:https://bugs.openjdk.java.net/browse/JDK-8204963
webrev: http://cr.openjdk.java.net/~psadhukhan/8204963/webrev.0/

8152159 testcase also worked well.

Regards
Prasanta



More information about the swing-dev mailing list