From efe9b67f134e05553f1ebfced3161a09108584e7 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Tue, 6 Aug 2024 13:09:22 -0700 Subject: [PATCH] Make sure get_total_soh_stable_size never return zero --- src/coreclr/gc/gc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 1d148ad33030d..4f15f554ffb41 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -22912,6 +22912,12 @@ size_t gc_heap::get_total_soh_stable_size() total_stable_size += hp->generation_size (max_generation - 1) / 2; } + if (!total_stable_size) + { + // Setting a temp value before a GC naturally happens (ie, due to allocation). + total_stable_size = dd_min_size (g_heaps[0]->dynamic_data_of (max_generation - 1)); + } + return total_stable_size; } }