iOS has no garbage collection mechanism, OC has garbage collection mechanism, MAC has garbage collection mechanism, MAC is enabled after version 10.1
MRC (reference count) manually assign and release
Alloc Allocating space
Retain Introduction count plus 1
Copy replication (another space, same as the original)
Release released, reference count minus 1
Autorelease minus 1 At some point in the future.
Dealloc Clear
Problems in memory: memory overflow, wild pointer
GC: Garbage collection mechanism, can automatically determine that those memory is no longer used by the system to help us recycle
MRC: Manual memory management, also called Manual reference counting, is our own judgment that the memory is still in use, and how many people are using it. When the reference count is 0, the memory is freed and the pointer is empty, preventing the wild pointer
ARC: Automatic memory management, also called automatic reference counting, when we need reference count-1, the compiler helps us add the release statement
OC provides a garbage collection mechanism, but iOS does not use
Mac OS 10.8 uses a garbage collection mechanism before 10.8 is deprecated.
Some methods of reference counting
+alloc: Open memory, set reference count to 1.
-retain: Make reference count +1.
-copy: Assigns a copy of memory or an object and resets the copied memory or object reference count to 1.
-release: Make reference count-1.
-autorelease: Make reference count-1, but only after the auto-release pool is executed-1 operation
-dealloc: When the reference count is 0 o'clock, it is automatically called by the system to free up space
There are two forms of the auto-release pool: (First use preferred)
The first type: @autorelease {}
The second type: NSAutoreleasePool *pool=[[nsautoreleasepool alloc] init];
[Pool release];
When release has been released for 0 o'clock, it will cause excessive release.
iOS Memory Trivia