The CLR memory allocation is divided into three chunks: Stack, GC heap, and large object heap.
One, thread stack (stack)
Used to assign a value type instance. The stack is managed by the operating system and is not managed by the GC, and its occupied stack space is automatically freed when the value type is not in its scope (primarily the function in which it resides). The execution efficiency of the stack is very high.
Second, GC heap (heap)
Used to allocate small object instances. The so-called small object is an instance object of size less than 85000 bytes. GC Heap is managed by three generations of garbage, and when GC operations (garbage collection) are performed, the garbage collector compresses the GC heap. The specific GC operation (slightly).
Three, large Object heap (LOH)
Used to allocate large object instances. A large object is an instance object that is less than 85000 bytes in size. Large objects are allocated on the Loh, are not controlled by GC, are not compressed, and are recycled only when fully GC is reclaimed.
Attention
A. The allocation of stacks is to the low address extension, and the heap allocation is to the high address extension.
B. The value parameter is the essence of the reference parameter, and the value parameter is a copy of the data in the stack, and the reference parameter is a reference to the stack address. When the value parameter is a reference object, you can change some values of the Reference object, but you cannot change the value to the address of the new object.
C. Objects in the heap have Synchronous block index (4 bytes), type handle (4 bytes)
D. Static fields, static methods, and methods that are assigned to and-----method tables
C # Memory allocation learning