From 6cc44d5b2673d047592aded9f49343e2afde25d1 Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Fri, 29 Mar 2024 06:05:10 -0700 Subject: [PATCH] Make sure we compact the LOH when aggressive GC is requested (#98954) --- src/coreclr/gc/gc.cpp | 8 +++++++- src/coreclr/gc/gcrecord.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index b422ae9b9175ff..40cb8694fd4d52 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -20825,6 +20825,12 @@ int gc_heap::joined_generation_to_condemn (BOOL should_evaluate_elevation, } } + if (settings.reason == reason_induced_aggressive) + { + gc_data_global.gen_to_condemn_reasons.set_condition (gen_joined_aggressive); + settings.loh_compaction = TRUE; + } + #ifdef BGC_SERVO_TUNING if (bgc_tuning::should_trigger_ngc2()) { @@ -31148,7 +31154,7 @@ BOOL gc_heap::plan_loh() void gc_heap::compact_loh() { - assert (loh_compaction_requested() || heap_hard_limit || conserve_mem_setting); + assert (loh_compaction_requested() || heap_hard_limit || conserve_mem_setting || (settings.reason == reason_induced_aggressive)); #ifdef FEATURE_EVENT_TRACE uint64_t start_time = 0, end_time; diff --git a/src/coreclr/gc/gcrecord.h b/src/coreclr/gc/gcrecord.h index 44641157e9f1bb..b611e7c0c1c4f8 100644 --- a/src/coreclr/gc/gcrecord.h +++ b/src/coreclr/gc/gcrecord.h @@ -73,7 +73,8 @@ enum gc_condemn_reason_condition gen_joined_servo_postpone = 27, gen_joined_stress_mix = 28, gen_joined_stress = 29, - gcrc_max = 30 + gen_joined_aggressive = 30, + gcrc_max = 31 }; #ifdef DT_LOG