From 1cfdca91a28f50e98dade886b02e709d5c72ec55 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Tue, 31 Oct 2017 00:32:38 +0200 Subject: [PATCH] [sgen] Collect major after user requested minor collections After a user requested minor collection we need to check if the new size of the heap exceeds the allowance, in which case we need to also do a major collection. Fixes bug (#60168) where, if user triggers minors repeatedly, we never get to collect the major space (which is normally checked after the nursery is full, which never happens in this case) --- mono/sgen/sgen-gc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index 4e622b11c399..fb3be3507b18 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -3089,6 +3089,9 @@ sgen_gc_collect (int generation) if (generation > 1) generation = 1; sgen_perform_collection (0, generation, "user request", TRUE, TRUE); + /* Make sure we don't exceed heap size allowance by promoting */ + if (generation == GENERATION_NURSERY && sgen_need_major_collection (0)) + sgen_perform_collection (0, GENERATION_OLD, "Minor allowance", FALSE, TRUE); UNLOCK_GC; }