The storage sequence should be managed when stored in the stack, and the principle of going out is maintained. It is a continuous memory domain with automatic distribution and maintenance.
The heap is unordered. It is a non-sequential memory domain, and users can control and release it themselves. If the user does not release the memory, when the memory reaches a certain value, the garbage collector (GC) is used for garbage collection.
The reference type is always stored in the heap.
Value types and pointers are always placed in the declared places.
Call method: the system first places an encoding Code (the first address of the heap) on the stack and then places the parameters of the method. ThenCodeWhen the method is executed, find all the parameters for putting the heap header address in the stack and control the heap through the heap header address.
Reference Type: Always in the heap.
When we use a reference type, we are actually processing the pointer of this type. Instead of the reference type itself, the value type is used.