.Net memory types
.Net uses several types of memory like stack, unmanaged heap and the managed heap.
Stack :
· It is managed on a per thread basis and is used to store local variables, method parmaters and temporary values.
· GC doesn’t clean stack as its get automatically cleaned when the method returns.
· The refrences to objects is stored on the stack but the actual object gets allocated on heap and GC is aware of that. When the GC could not find a refrences for an object it removes it from the heap.
Unmanaged Heap: Unmanaged code will allocate objects on the unmanaged heap or stack.
Managed Heap: Managed code allocates objects on managed heap and GC takes care of management of managed heap. GC also maintains a Large Object Heap to compensate the cost of moving large objects in memory.