JDK-8253960 : Memory leak in Java_java_lang_ClassLoader_defineClass0()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 15,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-10-02
  • Updated: 2020-12-07
  • Resolved: 2020-10-05
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 15 JDK 16
15.0.2Fixed 16 b19Fixed
Related Reports
Relates :  
Description
It is very obvious.

iff --git a/src/java.base/share/native/libjava/ClassLoader.c b/src/java.base/share/native/libjava/ClassLoader.c
index 31b3d814337..021a5a191eb 100644
--- a/src/java.base/share/native/libjava/ClassLoader.c
+++ b/src/java.base/share/native/libjava/ClassLoader.c
@@ -260,7 +260,7 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
         utfName = NULL;
     }
 
-    return JVM_LookupDefineClass(env, lookup, utfName, body, length, pd, initialize, flags, classData);
+    result = JVM_LookupDefineClass(env, lookup, utfName, body, length, pd, initialize, flags, classData);
 
  free_body:
     free(body);

Comments
Fix Request (15u) This fixes the obvious memory leak on common path, regression in 15. Patch applies cleanly to 15u, passes tier{1,2}.
30-11-2020

This looks like memory leak on a common path, even though introduced during Hidden Classes work. So, should we consider it for 15.0.2?
30-11-2020

Seems to be introduced by JDK-8238358.
30-11-2020

This issue impacts Lookup.defineClass, it's not an issue for the ClassLoader API.
05-10-2020

Changeset: 19219a96 Author: Zhengyu Gu <zgu@openjdk.org> Date: 2020-10-05 13:09:42 +0000 URL: https://git.openjdk.java.net/jdk/commit/19219a96
05-10-2020