1. We talked about the memory management base in OC, and we'll summarize when we should use memory management.
1) When you create an object with new, alloc, copy, you must release the object.
2) When you have an object, you do not need to release it if it is a temporary object, and you must preserve the object and dispose of the object in the Dealloc method when you need to persist the object for a long time.
Garbage collection mechanism in 2.OC
OC2.0 introduced the garbage collection mechanism, that is, after enabling the garbage collection mechanism, we forgot to release the object, OC will help us to release the object, which shows the power of OC than C + +.
The main principle of garbage collection mechanism is to dynamically track objects in the run , check the object's reference technology and clean up, garbage collection only support Mac,ios not support, because the dynamic release during the operation, not applicable to mobile app, so Apple introduced arc to solve the problem. It is important to note that the XCODE6 settings I am using now have no garbage collection mechanism set up.
ARC mechanism in 3.IOS
The ARC (automatic reference counting) mechanism is similar to the garbage collection mechanism, and will help you manage the life cycle of your objects. The difference is that the garbage collection mechanism decides to dispose of objects at runtime, and arc is the compiler that secretly adds the retain and release methods to our code at compile time. We can select the project and convert the project through the menu Edit->refactor->convert to Objective-c arc. ARC works only on ROP objects. Refer to the OC Basics Tutorial Live Apple's Official document Https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC /introduction/introduction.html.
OBJECTIVE-C Basic 3: Memory management continued