RFR: 8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc
Ivan Walulya
iwalulya at openjdk.org
Fri Jan 9 11:59:17 UTC 2026
Hi,
Please review this change which modifies the defaults for the `MinHeapFreeRatio` and `MaxHeapFreeRatio` flags in G1 so that they do not affect heap sizing unless explicitly set by the user.
Previously, these flags could trigger heap resizing at the end of Full GC, potentially overriding the G1 ergonomic heap sizing heuristics, which may be unexpected for the user. In particular, for workloads that frequently invoke `System.gc()`, the heap could shrink at the end of the Full GC and then expand aggressively during subsequent GCs (see image below).
<img width="2066" height="1198" alt="shrink_expand_flip_flop" src="https://github.com/user-attachments/assets/5d535178-be92-4b60-986d-8c1422451fff" />
With this update, the default values for `MinHeapFreeRatio` and `MaxHeapFreeRatio` no longer affect heap resizing. These flags will only take effect when explicitly set by the user..
Additionally, pause times from user-triggered `System.gc()` invocations will be excluded from the data used to update heap sizing heuristics. Because these GCs are user-initiated and do not reflect actual GC pressure, including their pause times can skew GC Pause Time ratios used for heap sizing decisions.
Testing: Tier 1 and JavaPerf.
-------------
Commit messages:
- update
- Merge branch 'master' into G1ResizeAfterFullGC_v1
- Ignore Defaults MinHeapFreeRatio-MaxHeapFreeRatio
- init
Changes: https://git.openjdk.org/jdk/pull/29137/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29137&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8238686
Stats: 47 lines in 4 files changed: 17 ins; 7 del; 23 mod
Patch: https://git.openjdk.org/jdk/pull/29137.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29137/head:pull/29137
PR: https://git.openjdk.org/jdk/pull/29137
More information about the hotspot-gc-dev
mailing list