RFR: 8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc [v2]
Ivan Walulya
iwalulya at openjdk.org
Wed Jan 14 11:56:03 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.
Ivan Walulya has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
- Merge remote-tracking branch 'upstream/master' into G1ResizeAfterFullGC_v1
- update
- Merge branch 'master' into G1ResizeAfterFullGC_v1
- Ignore Defaults MinHeapFreeRatio-MaxHeapFreeRatio
- init
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/29137/files
- new: https://git.openjdk.org/jdk/pull/29137/files/c4ec4b58..c60fed23
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29137&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29137&range=00-01
Stats: 34141 lines in 412 files changed: 21926 ins; 7900 del; 4315 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