RFR: 8364090: Dump JFR recording on CrashOnOutOfMemoryError [v4]

Erik Gahlin egahlin at openjdk.org
Wed Jul 30 07:15:56 UTC 2025


On Wed, 30 Jul 2025 05:13:42 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

>> Using an EventStream might simplify the filtering, e.g.
>> 
>>         AtomicLong oldObjects = new AtomicLong();
>>         AtomicReference<String> reason = new AtomicReference<>();
>>         try (EventStream stream = EventStream.openFile(...)) {
>>             stream.onEvent("jdk.Shutdown", e -> reason.set(e.getString("reason")));
>>             stream.onEvent("jdk.OldObjectSample", e -> oldObjects.incrementAndGet());
>>             stream.start();
>>         }
>>         if (shouldCrash) {
>>             // validation
>>         }
>
> I updated the test. I hope it works on your environment.
> 
> - Revise JVM option for the test process (`-Xmx` and `-XX:TLABSize` are copied from TestClassLoaderLeak.java)
> - Use `EventStream` to check JFR events as Erik shown
> - Repeat the test if `OldObjectSample` does not appear on the flight record
> - Remove `var` from test code

I will try running it. I think readability can be improved if everything under shouldCrash is grouped together, e.g.


if (oldObjects.get() > 0L) {
    if (shouldCrash) {
        Asserts.assertEquals("VM Error", shutdownReason.get());
        Asserts.assertEquals("Out of Memory", dumpReason.get());
    } else {
        Asserts.assertEquals("No remaining non-daemon Java threads", shutdownReason.get());
    }
    return;
}

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26468#discussion_r2241742584


More information about the hotspot-jfr-dev mailing list