.NET स्वयंचलितपणे garbage collector (GC) द्वारे memory व्यवस्थापित करते — हे managed heap वर objects allocate करते आणि जे पुढे reachable नाहीत त्यांना reclaim करते, म्हणून आपल्याला manually memory free करावी लागत नाही. GC समजून घेणे (generational, stack/heap split, आणि IDisposable) performance आणि correctness साठी महत्वाचे आहे.
Stack विरुद्ध heap
Stack → value types (locals), method frames; fast, automatically freed when scope ends.
Heap → reference type objects (class instances); managed by the GC.
A reference variable lives on the stack but points to its object on the heap.
