RFR: 8316661: CompilerThread leaks CodeBlob memory when dynamically stopping compiler thread in non-product

Vladimir Kozlov kvn at openjdk.org
Thu Sep 21 19:40:54 UTC 2023


On Thu, 21 Sep 2023 11:18:36 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi all,
> 
>   please review this change to fix a memory leak I found when having `CodeCache::free` call the destructor of `CodeBlob`: when adding the latter, one gets assertion failures that the native memory that `_asm_remarks` and `_dbg_strings` members were not deallocated properly when
> * stopping a compiler thread due to dynamic compiler thread policy
> * shutting down the compiler runtime
> 
> Testing: gha
> 
> Thanks,
>   Thomas

src/hotspot/share/code/codeCache.cpp line 609:

> 607:   cb->~CodeBlob();
> 608:   // Get heap for given CodeBlob and deallocate
> 609:   get_code_heap(cb)->deallocate(cb);

I am not sure it look correct - `cb` is used after you call destructor.
I think it works because destructor only has assert but I don't think it is right thing to do here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15858#discussion_r1333521770


More information about the hotspot-compiler-dev mailing list