Description
Description
DynamicOffHeapSizingMemoryTarget relies on JVM heap shrinking (returning committed heap pages to the OS) to reclaim memory for off-heap usage. The static initializer already checks for -XX:+ExplicitGCInvokesConcurrent and -XX:+DisableExplicitGC, which would prevent shrinking from working.
However, it misses the case where -Xms == -Xmx (or nearly equal). When the heap size is fixed, Runtime.getRuntime().totalMemory() is always equal to maxMemory(), meaning System.gc() can free objects but cannot shrink the committed heap. The shrinkOnHeapMemory mechanism becomes ineffective in this scenario.
Expected Behavior
The static initializer should detect when the initial committed heap is already at (or very close to) max heap size, and log an error indicating that JVM shrinking will not work.
Environment
All JDK versions with dynamic off-heap sizing enabled.
Gluten version
main branch
Description
Description
DynamicOffHeapSizingMemoryTargetrelies on JVM heap shrinking (returning committed heap pages to the OS) to reclaim memory for off-heap usage. The static initializer already checks for-XX:+ExplicitGCInvokesConcurrentand-XX:+DisableExplicitGC, which would prevent shrinking from working.However, it misses the case where
-Xms == -Xmx(or nearly equal). When the heap size is fixed,Runtime.getRuntime().totalMemory()is always equal tomaxMemory(), meaningSystem.gc()can free objects but cannot shrink the committed heap. TheshrinkOnHeapMemorymechanism becomes ineffective in this scenario.Expected Behavior
The static initializer should detect when the initial committed heap is already at (or very close to) max heap size, and log an error indicating that JVM shrinking will not work.
Environment
All JDK versions with dynamic off-heap sizing enabled.
Gluten version
main branch