On Thu, 4 Feb 2021 15:48:16 GMT, Thomas Stuefe <stu...@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 >> 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 > > Hi Cleas, > > looks good but why changing the the NULL comparisons? > > If you wanted to simplify you could completely omit the NULL checks since > free(NULL) is a noop. And potentially merge the labels - where there are two > - into one. > > Cheers, Thomas I'm not sure every platform have always agreed free(NULL) is a noop. I suspect all the currently supported ones do, though? ------------- PR: https://git.openjdk.java.net/jdk/pull/2407