RFR: 8369219: JNI::RegisterNatives causes a memory leak in CodeCache [v4]
    Francesco Andreuzzi 
    fandreuzzi at openjdk.org
       
    Wed Oct 22 14:17:44 UTC 2025
    
    
  
On Tue, 21 Oct 2025 23:19:48 GMT, Dean Long <dlong at openjdk.org> wrote:
>> 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?
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 two separate chunks:
- allow not-entrant nmethod to be collected during GC
- review and possibly remove entry barriers for native wrappers
Would you agree with this @dean-long ? I could create another ticket to handle the second part.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27742#discussion_r2452257035
    
    
More information about the hotspot-compiler-dev
mailing list