Re: __weak pointer collection firing prematurely???
Re: __weak pointer collection firing prematurely???
- Subject: Re: __weak pointer collection firing prematurely???
- From: Quincey Morris <email@hidden>
- Date: Mon, 13 Aug 2012 09:56:20 -0700
On Aug 13, 2012, at 09:01 , Kyle Sluder <email@hidden> wrote:
> As was discussed on the objc-language list recently, the ARC spec specifically guarantees that an object's lifetime includes the entire duration of a method invocation. An object *cannot* be deallocated while one of its methods is executing.
That was only under the assumption that the receiver's pointer was loaded from a weak variable.
It'll also be true if the receiver's pointer is loaded from a strong stack variable (because the stack reference's lifetime cannot end before the receiver's method is called -- even under optimization -- and there isn't AFAICT any subsequent way for it to end until the receiver's method returns).
However, if the receiver's pointer is loaded from a *strong* instance variable, there's no memory management applied to it. It's not retained when loaded (which I just verified by looking at a disassembly), and it's not retained on entry to the method itself (the Clang ARC spec explains why not). Setting the strong ivar to nil during the method execution would be a really bad idea.
At least, that's how I understand the situation.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden