JDK-8233958 : Memory retention due to HttpsURLConnection finalizer that serves no purpose
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8,11,14
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-11-08
  • Updated: 2020-11-30
  • Resolved: 2019-11-13
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 13 JDK 14
11.0.10-oracleFixed 13.0.6Fixed 14 b23Fixed
Description
A DESCRIPTION OF THE PROBLEM :
We have a system that posts lots of (potentially) large messages via HTTPS using a HttpsURLConnections.  The underlying HttpURLConnection implementation holds the transmitted data in internal buffers after posting with no way for us to clear them.  Normally this would not be an issue because when we release our HttpsURLConnection references the objects would be garbage collected.  Unfortunately HttpsURLConnectionImpl exposes a finalizer and so when our system is under load we find that the objects build up in the finalization queue which is only cleared by a low priority thread that does not get to run due to the increased load caused by the garbage collection overhead caused by the low memory state.  This then becomes a vicious circle causing the system to become extremely unstable.  There have been many bugs raised relating to this area raised in the past, eg: https://bugs.openjdk.java.net/browse/JDK-6869672 and its associated related bugs.  The underlying issue of the finalizer never seems to have been addressed but looking at the latest code:

sun.net.www.protocol.https.HttpsURLConnectionImpl has a finalizer which simply invokes sun.net.www.protocol.https.DelegateHttpsURLConnection.dispose().  This dispose method only invokes super.finalize().  There is no implementation of super.finalize() other than the empty implementation in java.lang.Object and so the finalizer has no purpose and should be removed.




Comments
Fix request (13u) Should be ported here, too. Fix applies clean, tier[123] tests pass.
30-11-2020

Fix Request (11u) The same problem affects 11u, and it does put unnecessary GC pressure on the JVM. I have inspected the class hierarchy in 11u, and this removal does look benign: there are no non-trivial finalizers. Patch applies cleanly to 11u, passes tier1, tier2, tier3 suites on Linux x86_64.
03-02-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/6c78185c99d7 User: michaelm Date: 2019-11-13 09:15:13 +0000
13-11-2019

Sounds reasonable. Suggested change looks benign.
12-11-2019