.NET, memory'yi otomatik olarak bir garbage collector (GC) aracılığıyla yönetir — nesneleri managed heap'e allocate eder ve artık erişilemeyen nesneleri geri kazanır, bu nedenle memory'yi manuel olarak serbest bırakmak zorunda değilsiniz. GC'yi anlamak (generational, stack/heap split'i ve IDisposable'ı) performans ve doğruluk açısından önemlidir.
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.
