C# › Memory & Garbage Collection

What causes managed memory leaks despite the GC?

Advanced

Answer

Objects stay reachable unintentionally: static references, un-removed event handlers, long-lived caches, or captured closures. The GC can't collect what is still referenced.
StaticCache.Add(bigObject); // never removed -> leak
Real-world example An ever-growing static dictionary cache slowly exhausts memory in a long-running service.