Integrated: 8261154: Memory leak in Java_java_lang_ClassLoader_defineClass0 with long class names

Claes Redestad redestad at openjdk.java.net
Fri Feb 5 09:01:42 UTC 2021


On Thu, 4 Feb 2021 14:23:56 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> This patch resolves a potential memory leak in Java_java_lang_ClassLoader_defineClass0
> 
> I've not figured a good way to write a regression test. A crude way to manually verify the leak and the fix is provided by the added microbenchmark that triggers the malloc in ClassLoader.c and the associated leak.
> 
> E.g., running this with `/usr/bin/time -v $BUILD_DIR/images/jdk/bin/java -Xmx256m -jar $BUILD_DIR/images/test/micro/benchmarks.jar LookupDef.*WeakClass.loadLong -f 0 -i  N | grep "Maximum resident set"` yields:
> 
> Baseline:
> N = 20     Maximum resident set size (kbytes): 544860
> N = 50     Maximum resident set size (kbytes): 818532
> N = 100    Maximum resident set size (kbytes): 1388560
> N = 200    Maximum resident set size (kbytes): 2124296
> Patch:
> N = 20     Maximum resident set size (kbytes): 480476
> N = 50     Maximum resident set size (kbytes): 764040
> N = 100    Maximum resident set size (kbytes): 782920
> N = 200    Maximum resident set size (kbytes): 921272

This pull request has now been integrated.

Changeset: 07918995
Author:    Claes Redestad <redestad at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/07918995
Stats:     79 lines in 2 files changed: 79 ins; 0 del; 0 mod

8261154: Memory leak in Java_java_lang_ClassLoader_defineClass0 with long class names

Reviewed-by: stuefe, chegar, mchung

-------------

PR: https://git.openjdk.java.net/jdk/pull/2407


More information about the core-libs-dev mailing list