Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#finalization queue and GC.CollectSingle-choice MCQ

Why is calling `GC.Collect()` immediately followed by needing the finalizers to have completed (e.g. before measuring memory) insufficient with just `GC.Collect()` alone, and what is the correct deterministic pattern?

GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();