One, garbage collection mechanism (GC garbage collection):
1. The memory used by a system-level thread is automatically checked for the release of useless objects.
2, garbage collection mechanism has multiple different algorithms to implement garbage collection mechanism. But the whole idea is to find useless objects-> Reclaim space occupied by useless objects.
3, the advantages and disadvantages of garbage collection mechanism:
Advantages: Automatically frees up memory, simplifies programming, and improves programming efficiency. Prevents memory leaks and ensures security.
Cons: The JVM must trace the objects that are useful in the program, freeing the useless objects, which takes processor time, and the overhead affects the performance of the program. The advantages and disadvantages of the proposed algorithm have a great impact on the efficiency of garbage collection.
Second, arc (Automatic Reference counting automatic reference count)
1, in short, is the code automatically added to the Retain/release, the original need to manually add the reference count to handle memory management of the code can be automatically completed by the compiler.
2. ARC is not a GC, it is just a static analyzer tool for code.
Iii. MRC (Manual Reference Counting manual reference count)
1, when the Retaincount is zero, will automatically call the object's Dealloc method for memory release recovery, we should never manually call the object's Dealloc method.
Iv. Initialization issues
1. New and Alloc/init are almost identical in function, allocating memory and completing initialization. The difference is that the new method can only be initialized with the default Init method, which is used in a alloc way, with other custom initialization methods.
2, Alloc when the object memory size configuration, the size of the memory by the object's properties, instance variables, methods of memory address synthesis. Alloc is simply the configuration of the address memory for variables and methods, and the exact size of the attributes and variables is dynamically non-matching at init time.