Cocoa employs a technique called reference counting, sometimes called a retention count. Each object has an integer associated with it, called its reference counter or reserved counter. When a piece of code needs to access an object, the code adds 1 of the object's retention counter value, which means "I want to access the object." When this code ends the object access, the object's retention counter value is reduced by 1, indicating that it no longer accesses the object. When the hold counter value is 0 o'clock, it means no longer has code access to the object, so the object is destroyed and its occupied memory is reclaimed by the system for reuse.
When you use the Alloc,new method or create an object by using a copy message that generates a replica of the receiving object, the object's retention counter value is set to 1. To increase the retention counter value of an object, you can send an retain message to the object. To reduce the retention counter value of an object, you can send an release message to the object.
Objective-c automatically sends an DEALLOC message to an object when an object is about to be destroyed because its retention counter is 0. You can override the Dealloc method in your own object. You can release all related resources that have been allocated in this way. Be sure not to call the Dealloc method directly. You can use Objective-c to call the Dealloc method when you need to destroy an object. To get the current value of the hold counter, you can send a retaincount message.
Reference: "Objective-c Basic Course"
"Reading notes" ios-reference counting