Overriding -release to break retain cycle. Was: Doc for -release not quite true
Overriding -release to break retain cycle. Was: Doc for -release not quite true
- Subject: Overriding -release to break retain cycle. Was: Doc for -release not quite true
- From: Jerry Krinock <email@hidden>
- Date: Sun, 29 Aug 2010 14:58:12 -0700
On 2010 Aug 23, at 19:02, Daniel DeCovnick wrote:
> But it doesn't really matter since you should never be calling dealloc except from release or dealloc (as [super dealloc];) anyway.
No, I haven't called -dealloc for quite a few years :)
Actually, I was studying Uli Kusterer's old UKKQueue. One of his instances detaches a secondary thread with the instance itself as target, creating a kind of retain cycle: The secondary thread won't exit until the instance is deallocced, and the instance won't be deallocced until the secondary thread exits. To fix this, he overrode -release, and messages (via ivar) the secondary thread to exit when the pre-release retainCount == 2. I believe it is a pretty neat trick, but couldn't understand it until I corrected Apple's documentation of -release.
Document Feedback has been submitted on -release.
_______________________________________________
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