.NET ले स्वचालित रूपमा garbage collector (GC) मार्फत memory को व्यवस्थापन गर्छ — यसले objects लाई managed heap मा आबंटित गर्छ र जो अब पहुँचयोग्य छैनन् तिनलाई पुनः प्राप्त गर्छ, त्यसैले तपाईंले म्यानुअली memory मुक्त गर्नु पर्दैन। GC (generational, stack/heap split, र IDisposable) बुझ्नु performance र correctness को लागि महत्त्वपूर्ण छ।
Stack vs 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.
