JDK-8204963 : javax.swing.border.TitledBorder has a memory leak
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9,10,11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2018-06-12
  • Updated: 2022-06-03
  • Resolved: 2018-08-09
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 11 JDK 12
11.0.10-oracleFixed 12 b14Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Pure Java bug - any instance of JDK 10.0.1

A DESCRIPTION OF THE PROBLEM :
The method javax.swing.border.TitledBorder.installPropertyChangeListeners() makes an anonymous listener object with a weak reference to TitledBorder. However, this logic is flawed as the listener object contains a hard reference (this$0) to the TitledBorder object, so the TitledBorder instance is never freed.

I actually see leaks in my application due to this. Screenshot: https://botcompany.de/1004590/raw/1101318


FREQUENCY : always



Comments
[~psadhukhan] Sent in the mail!
28-04-2022

[~yan] Since you told you had simpler, not headful test to verify this fix, would you be able to forward me the test?
28-04-2022

We are already in rampdown for July 2020. I don't see the urgency now as this bug was present in OpenJDK 11 from the get-go. Getting this into 11.0.9 seems fine.
04-06-2020

Fix request (11u): I'd like to add it to 11u as well. The patch applies cleanly. There's a problem with the test -- it doesn't work on my machine, see JDK-8213531 -- I've added another, someway simpler one, not headful etc. but it is not a fix to JDK-8213531 and perhaps should be sent to the current JDK -- or not necessary? Also, if possible, could I have it in July, 2020 release?
01-06-2020

URL: http://hg.openjdk.java.net/jdk/jdk/rev/cd7d2f9154fd User: prr Date: 2018-09-27 18:41:13 +0000
27-09-2018

URL: http://hg.openjdk.java.net/jdk/client/rev/cd7d2f9154fd User: psadhukhan Date: 2018-08-09 05:32:27 +0000
09-08-2018

As per description, javax.swing.border.TitledBorder has a memory leak with JDK versions 9 and onward. "The method javax.swing.border.TitledBorder.installPropertyChangeListeners() makes an anonymous listener object with a weak reference to TitledBorder. However, this logic is flawed as the listener object contains a hard reference (this$0) to the TitledBorder object, so the TitledBorder instance is never freed." When checked this for reported JDK version, could confirm the results. This seems a regression in JDK 9. Results: ======== 8u172: OK 9: Fail 10.0.1: Fail 11 ea b17: Fail To verify run the attached test case with respective JDK version. When run with JDK 11 ea b17 received below, Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
13-06-2018