RFR: 8214294: Post ResourceExhausted events generated by CompilerThread on the ServiceThread

Leonid Mesnik lmesnik at openjdk.org
Thu Jan 29 05:02:24 UTC 2026


On Thu, 29 Jan 2026 01:30:24 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> The 
>> 
>> [JDK-8213834](https://bugs.openjdk.org/browse/JDK-8213834) JVMTI ResourceExhausted should not be posted in CompilerThread
>> 
>> disables  posting ResourceExhausted events on CompilerThread because it can't post event. 
>> The ResourceExhausted is used by agents to identify VM issues (and usually kill instance). I think it makes sense to generate this event on the ServiceThread like other deferred events (methods loading/unloading). 
>> So tool like https://github.com/Netflix-Skunkworks/jvmquake can properly kill jvm if resource exhausting happens on any thread.
>> 
>> Please note, that ResourceExhausted is NOT generated when CodeCache full. It might be makes sense to add it since performance degradation going to be critical and makes sense treat CodeCache as a resource.
>> 
>> It is hard generate OOME in the CompilerThread to test this fix.
>> 
>> The fix was tested by patch that generated event for codecache exchausting and new test. 
>> https://github.com/openjdk/jdk/compare/master...lmesnik:jdk:codecache-full?expand=1
>
> In relation to the metaspace OOM the 2018 discussion (see JBS) indicates it is possible, but Thomas also notes:
>> If the JIT runs into metaspace OOM, it will cope by bailing out and leave that particular method uncompiled. I argue that this is not observable to the user and therefore ResourceExhausted can be suppressed.

@dholmes-ora Thank you for a feedback.
The goal was to call ResourceExhausted event when Compiler can't continue to work. The typical agent using ResourceExhausted usually kills application in this case, sometimes running some diagnostics.

The spec says
"Sent when a VM resource needed by a running application has been exhausted. Except as required by the optional capabilities, the set of resources which report exhaustion is implementation dependent."

and I think that it makes sense to notify users in the case if any of resources are exhausted.  However, I missed that this event should be posted on the thread that hit OOME.

Also, I thought if hitting CodeCache full deserves ResourceExhausted. The inability to compile methods usually is a huge problem in the real applications. Tool like jvmquake might benefit from handling these events.

Might be it would be better to add JVMTI_RESOURCE_EXHAUSTED_INTERNAL_VM that is triggered when VM is out of resources to continue to work normally.

I'll discuss this with serviceability team and rethink solution.

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

PR Comment: https://git.openjdk.org/jdk/pull/29397#issuecomment-3815497650


More information about the serviceability-dev mailing list