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

Dean Long dlong at openjdk.org
Tue Oct 21 23:22:18 UTC 2025


On Sat, 18 Oct 2025 10:13:42 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

>> I am tempted to say yes, for consistency, but it probably won't make much of a difference either way.  But now I am wondering, if these cold native wrappers continue to be immortal, then do they really need to give them nmethod entry barriers?  Removing the barrier could remove some overhead.  Whatever direction we decide to go, it would be good to add a comment here explaining the decision and/or trade-offs.
>
> Is it actually possible to remove entry barriers for _any_ garbage collectable nmethod? How can we know an nmethod is not used anymore, even when it is made not entrant? `is_cold()` bails out when an nmethod does not support entry barriers:
> 
> // On platforms that don't support nmethod entry barriers, we can't
> // trust the temporal aspect of the gc epochs. So we can't detect
> // cold nmethods on such platforms.
> 
> So, the decision of removing entry barriers for native nmethods would make the memory leak I'm trying to fix here effectively unfixable? Let me know if I'm missing something.

If we mark them as not-entrant, then the is_not_entrant() check below will still catch them, right?

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

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


More information about the hotspot-compiler-dev mailing list