Memory management and garbage collection

Memory management
stack (Stack) is a last in first out (FILO) some variables and data structures parameter stack memory stack are some simple value types can update the stack is in operation when the variable exceeds itself acting on automatically popped from the stack element is not continuously produce some garbage debris so stack mechanism is not needed to recover the data GC stack
heap (heap) stack without the stack is not characteristic LIFO order stack like a relatively large container for storing complex data types (such as reference type) and solving stack overflow problem occurs stack heap memory is stored in the data store random disordered understood as continuous data between them so that the stack is not prone to to clear debris after the extra garbage data can then sort the data needs to sort data plus dirty dirty flag convenient garbage record debris
still the main storage area of the static memory area after the program all global variables and static variables static zone running to wait until the end of the program before releasing
garbage collection
GC (GarbageCollect) GC mainly collected heap When the data in the data resource stack goes out of scope will not automatically pop heap to handle garbage collection is to determine whether there is a valid reference gameObject if gameobject is null then GC thought he was quoted by the garbage invalid resource recovery algorithm certainly not recover direct removal is accumulated to a certain owner starts garbage collection GC recovery is actually called a destructor (~ function name ()) after the amount of
 

Guess you like

Origin www.cnblogs.com/PJ-Mr-Zhang/p/11354647.html