From dd390e1dc53e2dbba917b03e3edbec28d0a1a2ee Mon Sep 17 00:00:00 2001 From: Peter Sollich Date: Mon, 22 May 2023 15:59:36 +0200 Subject: [PATCH] =?UTF-8?q?This=20fixes=20an=20issue=20with=20gradual=20de?= =?UTF-8?q?commit=20in=20scenarios=20where=20we=20have=20=E2=80=A6=20(#849?= =?UTF-8?q?75)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue with gradual decommit in scenarios where we have almost exclusively background GCs. The problem is that we turn off the gradual_decommit_in_progress_p flag and rely on the distribute_free_regions flag to turn it back on. If we only trigger a BGC however, distribute_free_regions won't get called and the flag will stay off, despite the global_regions_to_decommit list being non-empty. This will cause regions to accumulate in the global_regions_to_decommit list, and eventual will cause the process to run out of memory. The fix is to just test for the no gc region case in decommit_step. This will also turn off the gradual_decommit_in_progress_p flag for the no gc region case, but not for background GCs. --- src/coreclr/gc/gc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index efa3cc20a48c2..5ac965a1b0291 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -6848,7 +6848,6 @@ void gc_heap::gc_thread_function () END_TIMING(suspend_ee_during_log); proceed_with_gc_p = TRUE; - gradual_decommit_in_progress_p = FALSE; if (!should_proceed_with_gc()) { @@ -41526,6 +41525,12 @@ void gc_heap::decommit_ephemeral_segment_pages() // return true if we actually decommitted anything bool gc_heap::decommit_step (uint64_t step_milliseconds) { + if (settings.pause_mode == pause_no_gc) + { + // don't decommit at all if we have entered a no gc region + return false; + } + size_t decommit_size = 0; #ifdef USE_REGIONS