From 93d091ad35cccc9c7010ae6481a61feee7830e92 Mon Sep 17 00:00:00 2001 From: Liang Mao Date: Tue, 7 May 2024 13:20:39 +0000 Subject: [PATCH] 8314573: G1: Heap resizing at Remark does not take existing eden regions into account Backport-of: 762b652912939b37fbd68955617705c62b9fc3a5 --- src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp index 1a7c11a685b..8645b847045 100644 --- a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp @@ -217,7 +217,14 @@ size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand) { // Capacity, free and used after the GC counted as full regions to // include the waste in the following calculations. const size_t capacity_after_gc = _g1h->capacity(); - const size_t used_after_gc = capacity_after_gc - _g1h->unused_committed_regions_in_bytes(); + const size_t used_after_gc = capacity_after_gc - + _g1h->unused_committed_regions_in_bytes() - + // Discount space used by current Eden to establish a + // situation during Remark similar to at the end of full + // GC where eden is empty. During Remark there can be an + // arbitrary number of eden regions which would skew the + // results. + _g1h->eden_regions_count() * HeapRegion::GrainBytes; size_t minimum_desired_capacity = target_heap_capacity(used_after_gc, MinHeapFreeRatio); size_t maximum_desired_capacity = target_heap_capacity(used_after_gc, MaxHeapFreeRatio);