Understanding the various types of memory used in C#
There are two main types of memory in C#: the stack and the heap. The heap is further broken down into the small object heap and the large object heap. In terms of physical memory, there is no difference between the stack or heap, as they are both stored in physical memory. Their differences are in their implementations.
When your application starts up, it is allocated a portion of memory. A pointer will be assigned to your application that will be your application's memory starting point. Above the pointer will be the stack, and below the pointer will be the heap. The heap will grow downwards, and the stack will grow upwards, as shown in Figure 3.4:
The following diagram visually represents the stack and heap for a simple program:
To understand...