Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With the stack and heap parts of memory, which one is managed by the .NET garbage collector?

Tags:

c#

With the stack and heap parts of memory, which one is managed by the .NET garbage collector?

like image 220
Yves Avatar asked Dec 06 '25 07:12

Yves


2 Answers

Memory on the heap is managed by the garbage collector. Memory on the stack is deterministic and is returned to the pool when it goes out of scope.

like image 118
Yuriy Faktorovich Avatar answered Dec 07 '25 21:12

Yuriy Faktorovich


Just the (managed) heap. The stack may have references to objects, but not the objects themselves.

like image 23
Marc Gravell Avatar answered Dec 07 '25 20:12

Marc Gravell