1. If you need to keep an object from being destroyed, you can use retain. After you have finished using the object, you need to use release to destroy
2. Sending a release message to an object does not destroy the object, and the object is destroyed only if the object's reference count is reduced to 0 o'clock. The system then sends a DEALLOC message to the object to release its memory.
Releasing any object that uses the retain or Copy,mutablecopy,alloc or the new method, as well as properties with retain and copy attributes, requires overriding the Dealloc method so that the object can release the instance variables when it is disposed.
3. Objects that are automatically freed when the auto-release pool is emptied. The system sends a release message to each object in the pool each time the automatic release pool is destroyed. If the object reference count in the pool is reduced to 0, the system sends a DEALLOC message to destroy the object.
4. If the object is no longer needed in the method but needs to be returned, you can send an autorelease message to this object to mark the object for deferred release. The autorelease message does not affect the reference count of this object.
5. When the app terminates, the in-memory objects are freed, regardless of whether they are automatically freed from the pool.
When developing a cocoa or iOS application, the automatic release pool will be created and emptied as the application runs (each event will occur). In this case, if you want the automatic free pool to be emptied after an object that automatically frees the pool can also exist, the object needs to use the Retain method, as long as the reference count of these objects is greater than the number of autorelease messages sent to survive the pool being cleaned up.
and nbsp &NBS P &NBS P ; --excerpt from Objective-c programming version sixth
, &NB Sp , &NB Sp , &NB Sp --[Mei]stephen G.kochan
--Lin Fan Jun Zhu Yixin
Summary of manual memory management rules