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

Dean Long dlong at openjdk.org
Thu Oct 23 03:02:06 UTC 2025


On Wed, 22 Oct 2025 14:15:12 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

>> If we mark them as not-entrant, then the is_not_entrant() check below will still catch them, right?
>
> I see, I assumed an nmethod couldn't be marked as on-stack without entry barriers, but that doesn't seem to be the case.
> 
> But on second thought, do you agree with the fix I'm proposing in this PR? I think the following two work items could be implemented and reviewed in separate changesets:
> - Allow not-entrant nmethod to be collected during GC (I removed `is_static_method()` from L2599, so native nmethods are treated just like normal nmethods)
> - Evaluate the implications of removing entry barriers for native nmethods, thus letting GC reclaim them whenever `!is_maybe_on_stack() && is_not_entrant()`, but without the overhead of entry barriers.
> 
> I'm proposing this because I guess the latter will need more discussion and is technically not needed to fix the memory leak I address in this PR. Do you agree @dean-long ? I could create another ticket to handle the second item.

Yes, I'm fine with it being a separate issue.

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

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


More information about the hotspot-compiler-dev mailing list