From 96d711e8c3289fbeb2c6dbd26e8cf9e2b0971597 Mon Sep 17 00:00:00 2001 From: Kuai Wei Date: Wed, 11 Sep 2024 12:02:57 +0800 Subject: [PATCH] [JIT] Fix mem leak for ReduceNMethodSize Summary: free immutable data in nmethod::flush Testing: test/hotspot/jtreg/compiler/codecache/stress/UnexpectedDeoptimizationTest.java Reviewers: lusou.zq, yueshi.zwj Issue: https://github.com/dragonwell-project/dragonwell11/issues/861 --- src/hotspot/share/code/nmethod.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index d450d12fd51..ee27cfe1d11 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -1396,6 +1396,11 @@ void nmethod::flush() { assert(_speculation_log == NULL, "should have been nulled out when transitioned to zombie"); #endif + if (ReduceNMethodSize && _immutable_data_size > 0) { + assert(_immutable_data != data_end(), "must be"); + os::free(_immutable_data); + _immutable_data = data_end(); + } CodeBlob::flush(); CodeCache::free(this); }