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

Aleksey Shipilev shade at openjdk.org
Fri Oct 24 13:49:11 UTC 2025


On Thu, 23 Oct 2025 08:44:44 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:
> 
>  - cc
>  - Merge branch 'master' into JDK-8369219
>  - nn
>  - update foundOne
>  - fix summary
>  - nn
>  - Merge branch 'master' into JDK-8369219
>  - trigger
>  - nn
>  - othervm
>  - ... and 5 more: https://git.openjdk.org/jdk/compare/8965993a...b6d94cf8

Looks reasonable, but the test needs a bit more work.

test/hotspot/jtreg/gc/NativeWrapperCollection/NativeWrapperCollection.java line 62:

> 60:         WB.enqueueMethodForCompilation(method, 1 /* compLevel */);
> 61:         while (WB.isMethodQueuedForCompilation(method)) {
> 62:             Thread.onSpinWait();

We are just waiting for compilation here. It is counter-productive to wait with a busy-loop. Insert a sleep for ~10...100ms instead. Same thing for the loop below.

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

Marked as reviewed by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27742#pullrequestreview-3376819734
PR Review Comment: https://git.openjdk.org/jdk/pull/27742#discussion_r2460528080


More information about the hotspot-compiler-dev mailing list