On Nov 4, 2011, at 6:00 AM, Hamish Allan wrote:
> On 4 November 2011 12:43, Frank Illenberger <email@hidden> wrote:
>> does anybody know why when compiling with ARC, method arguments get retained? This happens even with full compiler optimizations enabled.
>> This is contradicts the ARC specification ( http://clang.llvm.org/docs/AutomaticReferenceCounting.html#optimization ) which reads:
>>> [snip] For example, if a retain and release immediately bracket a call, the optimizer can delete the retain and release [snip]
> Perhaps the retain occurs *after* the call, before the NSLog?
That is correct. When the compiler doesn't know anything about the memory management behavior of a function or method (and this happens a lot), then the compiler must assume:
1) That the function or method might completely rearrange or replace the entire object graph of the application (it probably won't, but it could).
2) That the caller might be manual reference counted code, and therefore the lifetime of passed in parameters is not realistically knowable.
Given #1 and #2; and given that ARC *must* never allow an object to be prematurely deallocated, then these two assumptions force the compiler to retain passed in objects more often than not.
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden