Skip to content

[CORE] DynamicOffHeapSizingMemoryTarget should warn when -Xms equals -Xmx #12479

Description

@xumanbu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions