From aca1e8365bf0f64bf18caf798bbca1d25b3c4117 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Tue, 30 Apr 2024 16:20:10 +0000 Subject: [PATCH] 8329223: Parallel: Parallel GC resizes heap even if -Xms = -Xmx Reviewed-by: ayang, gli --- src/hotspot/share/gc/shared/genArguments.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/gc/shared/genArguments.cpp b/src/hotspot/share/gc/shared/genArguments.cpp index 8e8abc6fb96..da9fc3f9a85 100644 --- a/src/hotspot/share/gc/shared/genArguments.cpp +++ b/src/hotspot/share/gc/shared/genArguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -276,6 +276,9 @@ void GenArguments::initialize_size_info() { // and maximum heap size since no explicit flags exist // for setting the old generation maximum. MaxOldSize = MAX2(MaxHeapSize - max_young_size, GenAlignment); + MinOldSize = MIN3(MaxOldSize, + InitialHeapSize - initial_young_size, + MinHeapSize - MinNewSize); size_t initial_old_size = OldSize; @@ -287,9 +290,8 @@ void GenArguments::initialize_size_info() { // with the overall heap size). In either case make // the minimum, maximum and initial sizes consistent // with the young sizes and the overall heap sizes. - MinOldSize = GenAlignment; initial_old_size = clamp(InitialHeapSize - initial_young_size, MinOldSize, MaxOldSize); - // MaxOldSize has already been made consistent above. + // MaxOldSize and MinOldSize have already been made consistent above. } else { // OldSize has been explicitly set on the command line. Use it // for the initial size but make sure the minimum allow a young @@ -304,9 +306,10 @@ void GenArguments::initialize_size_info() { ", -XX:OldSize flag is being ignored", MaxHeapSize); initial_old_size = MaxOldSize; + } else if (initial_old_size < MinOldSize) { + log_warning(gc, ergo)("Inconsistency between initial old size and minimum old size"); + MinOldSize = initial_old_size; } - - MinOldSize = MIN2(initial_old_size, MinHeapSize - MinNewSize); } // The initial generation sizes should match the initial heap size,