Integrated: 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
Wed Jan 21 09:53:26 UTC 2026
On Fri, 9 Jan 2026 11:39:24 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: b1340305
Author: Ivan Walulya <iwalulya at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/b1340305c8f5ea53b45b8bd3bd2ebe8f74864d40
Stats: 12 lines in 1 file changed: 11 ins; 0 del; 1 mod
8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc
Reviewed-by: tschatzl, sjohanss
-------------
PR: https://git.openjdk.org/jdk/pull/29137
More information about the hotspot-gc-dev
mailing list