Chapter 2: The Simple Heap Model
In Chapter 1, we saw how the stack is used to store value types and object pointers to reference types held on the heap. This enables every method called to retain the state of local variables between calls to other methods. We also touched on the heap itself, and how the creation, allocation, and destruction of objects are managed for us by the .NET runtime.
To really understand how the .NET framework manages memory for us, we need to look more closely at how heap allocation works.
To recap, when a .NET application runs, two sections of memory are reserved for storing objects allocated during execution (we'll ignore the other two sections of the heap for now). The memory sections are called the ...