From 14bdfeb08c9f34da2c3d2fdd470d7cb0bd3c9282 Mon Sep 17 00:00:00 2001 From: Xiaolong Peng Date: Mon, 4 May 2026 16:57:38 +0000 Subject: [PATCH] 8383772: runtime/reflect/ReflectOutOfMemoryError.java can fail intermittently on Shenandoah with small heaps Reviewed-by: kdnilsen, wkemper --- .../hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java b/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java index 69cfade4521..42f386d3f09 100644 --- a/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java @@ -38,7 +38,8 @@ public class ReflectOutOfMemoryError { try { // Repository for objects, which should be allocated: int index = 0; - for (int size = 1 << 30; size > 0 && pool == null; size >>= 1) + // Halving loop starting from max possible size constrained by max heap size + for (int size = (int)(Runtime.getRuntime().maxMemory()>>2); size > 0 && pool == null; size >>= 1) try { pool = new Object[size]; } catch (OutOfMemoryError oome) {