Memory & GC · interview question
Which statements about the .NET garbage collector are true? Select all that apply.
Select all that applyMedium
Answer and explanation
Correct answer
- A. It's generational, with Gen 0, Gen 1 and Gen 2.
- B. Objects of 85,000 bytes or more are allocated on the Large Object Heap.
- E. The GC can compact the heap, moving objects in memory.
Why
Most objects die young, so the GC collects Gen 0 often and cheaply. Survivors are promoted and the heap is compacted (the LOH isn't compacted by default). Use IDisposable for deterministic cleanup.
Test yourself on Memory & GC
A free test with instant, explained results. No account needed.