iOS- Memory Management

1. alloc, new, when the copy an object, the object's reference count is 1

  Reference count is 0, to release

2. retain +1

 release -1

 retainCount inaccurate

3. When the object reference count is 0 need to be destroyed, the system will call - (void) dealloc method must call [super dealloc] code and write back all

4. ARC (Automatic Reference Counting) automatic reference count

  The compiler will automatically add the retain / release methods in place

 MRC (Manul Reference Counting) reference count manually

5. Close ARC

6. zombie objects: the object is released

  Wild pointers: pointing to an object pointer zombie

  Enable zoobie objects

 7. Global breakpoints

 8. NSLog(@"%s", __func__)

9. The message sent to the null pointer is no response, the no error.

10. - (void)setPerson:(Person*)person{

  if(_person != person){

    [_person release];

    _person = [person retain];

}}

  - (void)dealloc{

  Object Properties release;

  [super dealloc];

}

11. @property(nonatomic, retain/assign) Person person;

  retain: automatically generate the code setter memory management

  assign: produces normal setter / getter code is not written, then assign default

  

  

Guess you like

Origin www.cnblogs.com/yintingting/p/12668936.html