This is a matter of ownership.
Let's talk about the NSString that you highlighted first. When you allocate an object, memory on the heap is reserved for this object (unless you allocateWithZone: to another location). The save count is implicitly 1, and you own the object, i.e. You are responsible for his release when you are done. If you are going to return a pointer to this object, i.e. By returning this object, you will not completely disclaim liability for the object not to leak. You cannot release it, because the save counter will be 0, and this object will be canceled. You automatically check this, ensuring that at the end of the execution loop (or earlier) the object will be released and possibly freed. The calling function is responsible for storing the returned object if the returned object must survive longer.
Without an auto-calculation pool, you will leak out because the designated autoReleasePool is null (remember that its value is null, so this is not just a failure, but just a leak).
The fixed @ example does not leak, because the compiler reserves the program memory for this line, and -release does not affect them. The same is true for some low value NSNumbers.
As James said, ARC does not remove the concept of conservation and auto-advertising.
EDIT: how is outName declared as ivar / property?
source share