diff --git a/src/hotspot/share/gc/g1/g1Arguments.cpp b/src/hotspot/share/gc/g1/g1Arguments.cpp index 58e76cdd43a..ffb06a7d822 100644 --- a/src/hotspot/share/gc/g1/g1Arguments.cpp +++ b/src/hotspot/share/gc/g1/g1Arguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -209,6 +209,17 @@ void G1Arguments::initialize() { FLAG_SET_DEFAULT(GCTimeRatio, 24); } + // Do not interfere with GC-Pressure driven heap resizing unless the user + // explicitly sets otherwise. G1 heap sizing should be free to grow or shrink + // the heap based on GC pressure, rather than being forced to satisfy + // MinHeapFreeRatio or MaxHeapFreeRatio defaults that the user did not set. + if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) { + FLAG_SET_DEFAULT(MinHeapFreeRatio, 0); + } + if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) { + FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100); + } + // Below, we might need to calculate the pause time interval based on // the pause target. When we do so we are going to give G1 maximum // flexibility and allow it to do pauses when it needs to. So, we'll