RFR: 8256916: Add JFR event for OutOfMemoryError

Erik Gahlin egahlin at openjdk.java.net
Tue Jan 12 21:59:56 UTC 2021


On Tue, 12 Jan 2021 06:59:37 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

>> @egahlin OOME from JVM will not be reported because they are instantiated at JVM init stage and are kept in `Universe`, so they cannot be handled in `ThrowableTracer::traceError`.
>> We can trace OOMEs which are happened in Java code at `ThrowableTracer::traceError`. However I'm not sure where the event should be handled in.
>> 
>> For sake of simply, I want to add `jdk.OutOfMemoryError` event to `jdk.jfr` module as a Java class, and I want to emit it from `ThrowableTracer::traceError`, however it duplicates with a definition in JVM.
>> OTOH we can implement to emit event from `ThrowableTracer::traceError` via `JVM` class, however need to add API to emit events with arbitrary arguments.
>
> `Universe` holds some of throwable objects such as `NullPointerException`, `VirtualMachineError`. They could be lost in flight record. This problem is not only for OOME.
> 
> So I think we need to track all `Throwable` objects in `Exceptions::_throw()` in HotSpot instead of bytecode injection.
> `ThrowableTracer` has a counter to track num of throwing (`numThrowables`) which is used in `ExceptionStatisticsEvent`, so we also need to track it in HotSpot.
> 
> I want to hear opinions about it before making changes.

The right way to do this is to emit the event when the exception is thrown and I think it must happen inside the VM. 

One problem is that the C2 compiler can eliminate the throw if it can prove the it can't be seen. That is the reason, we ended up with the current implementation many years ago. It was complicated to implement in the VM.

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

PR: https://git.openjdk.java.net/jdk/pull/1403


More information about the hotspot-jfr-dev mailing list