1. Memory management mechanism
- Referred to as "reference count" (retain counting)
- Each object has a reference count (retain count)
2. Why to manage memory
In our iOS development process, the program memory more than 20M will receive a memory warning, to 30M when the program will be a flash, this may be a lot of developers crash place.
The 3.iOS memory mechanism is mainly divided into ARC and MRC
- ARC automatically manages memory
- MRC Manual Memory Management
4. Principles of Memory management
- The essence of memory management is the management of memory reference count
- There are +1 must have corresponding-1
- Only when you see alloc,retain,copy, you need to releas in the current method or in the interior;
- When a pointer is retain,alloc,copy, it needs to be release within the current method or class.
- An object created by the convenience constructor, which has been identified within the method once Autorelease
- Container memory Management: An object is placed in the container, the reference count of this object +1, when the object is removed from the container, the object reference count will be-1.
5. How the system reclaims memory Dealloc
Never call this method
In the MRC, when you rewrite this method, you need to write a [super Dealloc] in the last line;
oc-Memory management mechanism