RFR: 8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc [v3]
Ivan Walulya
iwalulya at openjdk.org
Wed Jan 14 12:01:54 UTC 2026
On Wed, 14 Jan 2026 11:58:01 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.
>
> Ivan Walulya has updated the pull request incrementally with one additional commit since the last revision:
>
> Factor out change in flag defaults
Split the changes because the change in flag defaults needs to have a compatibility review.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29137#issuecomment-3749231641
More information about the hotspot-gc-dev
mailing list