From cbb3d23e19a8a893bf2fbda03e7bda4f4b7a59a6 Mon Sep 17 00:00:00 2001 From: Richard Reingruber Date: Wed, 16 Jul 2025 06:12:07 +0000 Subject: [PATCH] 8361827: [TESTBUG] serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java throws OutOfMemoryError Reviewed-by: clanger, syan --- .../HeapDump/UnmountedVThreadNativeMethodAtTop.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java index 2e3925a5ca7..bb08be91dac 100644 --- a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java +++ b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java @@ -38,6 +38,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import com.sun.management.HotSpotDiagnosticMXBean; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -49,6 +50,15 @@ public class UnmountedVThreadNativeMethodAtTop { boolean done; + /** + * The tests accumulate previous heap dumps. Trigger GC before each test to get rid of them. + * This makes dumps smaller, processing faster, and avoids OOMs + */ + @BeforeEach + void doGC() { + System.gc(); + } + /** * Test dumping the heap while a virtual thread is blocked entering a synchronized native method. */