RFR: 8369219: JNI::RegisterNatives causes a memory leak in CodeCache [v4]

Dean Long dlong at openjdk.org
Thu Oct 16 02:39:04 UTC 2025


On Sat, 11 Oct 2025 18:25:48 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

>> I propose to amend `nmethod::is_cold` to let GC collect not-entrant native `nmethod` instances.
>> 
>> Passes tier1 and tier2 (fastdebug).
>
> Francesco Andreuzzi has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update foundOne

src/hotspot/share/code/nmethod.cpp line 2599:

> 2597: // nmethods that don't seem to be all that relevant any longer.
> 2598: bool nmethod::is_cold() {
> 2599:   if (!MethodFlushing || (is_native_method() && is_in_use()) || is_not_installed()) {

So I guess we need to decide what to do about native wrappers that are still "in use", but are "cold" because they haven't been called in a while.  The above change would keep them around forever.  We could instead allow them to be cleaned up like regular nmethods.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27742#discussion_r2434399527


More information about the hotspot-compiler-dev mailing list