Generations, LOH and POH, GC modes, finalisation, IDisposable and IAsyncDisposable, weak references, memory leaks and GC pressure.
-
How does generational garbage collection work in .NET, and why does it make most collections cheap?
The generational hypothesis, Gen 0/1/2, promotion, card tables and write barriers, regions, and mark-sweep-compact.
Mid-Level
Theory
Garbage Collection
Β· π 4 follow-ups Β· π 1 real-world
-
What happens during a Gen 0 allocation and collection in .NET, and how do you reduce Gen 0 GC frequency?
Allocation contexts and bump-pointer allocation, the Gen 0 budget, what triggers a Gen 0 GC, allocation rate metrics and reducing allocations.
Mid-Level
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is the role of Gen 1 in the .NET GC, and what is the "mid-life crisis" problem?
Gen 1 as a buffer between short- and long-lived objects, Gen 1 GCs, objects that die soon after reaching Gen 2, and how to fix mid-life lifetimes.
Senior
Theory
Garbage Collection
Β· π 2 follow-ups Β· π 1 real-world
-
What is a Gen 2 (full) garbage collection in .NET, what triggers it, and how do you investigate frequent Gen 2 GCs?
Full GCs, triggers (budget, LOH allocation, induced, low memory), blocking versus background, compaction, and a method to diagnose frequent Gen 2 collections.
Senior
Debugging
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is the Large Object Heap (LOH) in .NET, and how do you find and fix LOH fragmentation and churn?
The 85,000-byte threshold, LOH collection with Gen 2, no compaction by default, fragmentation, churn, GCLOHThreshold and fixes such as pooling and streaming.
Senior
Debugging
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is the Pinned Object Heap (POH), and when should you allocate pinned arrays instead of using fixed or GCHandle?
Pinning, why it fragments the heap, the POH (.NET 5), GC.AllocateArray with pinned: true, its restrictions and typical uses such as I/O buffer pools.
Senior
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is Workstation GC in .NET, when is it the default, and when would you choose it over Server GC?
Workstation GC: single heap, background GC on by default, non-concurrent option, defaults per app type, and choosing it for desktop, tools and dense containers.
Mid-Level
Theory
Garbage Collection
Β· π 2 follow-ups Β· π 1 real-world
-
What is Server GC in .NET, how does DATAS change it in .NET 9 and later, and how do you tune it in containers?
Server GC heaps and threads, throughput versus memory, DATAS dynamic heap count (default with Server GC since .NET 9), and container settings such as GCHeapHardLimit and GCHeapCount.
Senior
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is the difference between background GC and the older concurrent GC in .NET, and how do GC latency modes affect pauses?
Concurrent versus background Gen 2 collection, foreground GCs during background GC, configuration naming, latency modes and no-GC regions.
Senior
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
How does finalisation work in .NET, why are finalisers expensive, and how do you diagnose a blocked finaliser thread?
Finalisation queue and f-reachable queue, extra GC survival, the single finaliser thread, ordering and exit behaviour, SafeHandle, and debugging finaliser problems.
Senior
Debugging
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
How do you implement IDisposable correctly, and who is responsible for disposing an object?
The dispose pattern, sealed simple Dispose, idempotency, ObjectDisposedException, ownership rules, DI container disposal and analyser support.
Mid-Level
Coding
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
How does the using statement work in C#, and what are the common bugs with using declarations, deferred execution and exceptions?
using statement versus declaration, lowering to try/finally, disposal order, pattern-based using for ref structs, and bugs with returned objects, deferred LINQ and Dispose exceptions.
Mid-Level
CodeReview
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
When should a type implement IAsyncDisposable, how does await using work, and how do you implement both IDisposable and IAsyncDisposable correctly?
IAsyncDisposable and ValueTask DisposeAsync, await using lowering, ConfigureAwait on disposal, the DisposeAsyncCore pattern, and DI async scopes.
Senior
Coding
Garbage Collection
Β· π 2 follow-ups Β· π 1 real-world
-
What are WeakReference and ConditionalWeakTable in .NET, and when are weak references the right tool?
Short and long weak references, WeakReference of T, ConditionalWeakTable for attached data, weak events, why weak caches are unreliable and their GC cost.
Senior
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
How do you investigate a memory leak in a .NET service in production, step by step?
Confirming a leak, managed versus native growth, dotnet-counters, dotnet-gcdump comparisons, dotnet-dump and gcroot, common leak sources and verifying the fix.
Senior
Debugging
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world
-
What is GC pressure in .NET, how do you measure it, and how do you reduce it (including GC.AddMemoryPressure for native memory)?
Allocation rate and time in GC as pressure metrics, practical reduction techniques, GCConserveMemory, AddMemoryPressure for native allocations, and RefreshMemoryLimit.
Senior
Theory
Garbage Collection
Β· π 3 follow-ups Β· π 1 real-world