vivek vivek - 15 days ago 8
Objective-C Question

Reference Counting ,ARC

Does the objects get deallocated instantly when the reference count goes to 0 or wait till encountering the release method (inserted automatically by compiler in ARC) explicitly for dealloc to happen ?

Answer

The whole issue with memory management is that it's difficult to make large programs where there's only a single, obvious place to free an object. If this were the case, there would be no need for reference counting at all!

The compiler inserts retain and release calls whenever references are made or destroyed. When release is called, the reference count is decremented. If in doing so the count reaches 0, deinit is called, and the object's memory is freed. This is all part of the release call.