Showing posts with label ARC. Show all posts
Showing posts with label ARC. Show all posts

Thursday, October 3, 2013

Memory Management in Objective C

In this topic, we will discuss Reference Counting and some other memory management topics related to Objective C.

Reference Counting


Reference Counting is a technique of storing a number of reference to an Object at any given state. As soon as the reference count goes to the Zero object is released from the memory. It is important from the development point of view of application where memory is critical and to maintain responsiveness. It is the most simple algorithm for memory management. 

Objective C provides two methods of Memory Management

  1. MRR - Manual Retain-Release: In this method, you explicitly keep track of the Objects you own. 
  2. ARC - Automatic Reference Counting uses the same algorithm of MRR, However, while using ARC Compiler insert appropriate statements in your code at compile time. 

Wednesday, September 11, 2013

Difference between Weak and Strong keywords

Strong means you want to keep control over the lifetime of the object. If an object is marked as strong mean object remains in the heap until you point that object strongly. If you send the object to nil only than it will be collected by the Garbage collection.

Weak means you don't want to keep control over the lifetime of the object. A weak reference does not extend the lifetime of the object it points to, and automatically becomes nil when there are no strong references to the object. If no one is pointing the object strongly than the object will be collected by the heap.


you can find more details about ARC(Automatic Reference Counting) Click Here...