• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Documentation for -release is not quite true
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Documentation for -release is not quite true


  • Subject: Re: Documentation for -release is not quite true
  • From: Daniel DeCovnick <email@hidden>
  • Date: Mon, 23 Aug 2010 19:02:53 -0700

That's exactly what Jerry just suggested was happening, however the documentation implies that it's implemented more like

-(oneway void)release
{
	self->retainCount--;
	if (0 == self->retainCount)
		[self dealloc];
}

But it doesn't really matter since you should never be calling dealloc except from release or dealloc (as [super dealloc];) anyway.

-Daniel

On Aug 23, 2010, at 6:47 PM, Gary L. Wade wrote:

> Have you considered that the code for -release may be implemented in a
> manner like this?
>
> -(oneway void)release
> {
>    if (1 == self->retainCount)
>    {
>        // Let's save a few CPU cycles and not bother
>        // decrementing retainCount since it won't be
>        // around for long.
>        [self dealloc];
>    }
>    else
>    {
>        self->retainCount--;
>    }
> }
>
> On 08/23/2010 6:35 PM, "Jerry Krinock" <email@hidden> wrote:
>
>> Kind of late in the decade for this, but anyhow, the documentation for
>> -release says:
>>
>> - (oneway void)release
>>   Decrements the receiver’s reference count.
>>   Discussion.  The receiver is sent a dealloc message when its reference
>> count reaches 0.
>>
>> So it's always bothered me that if I override -dealloc and log the retainCount
>> on the way in, it is 1, not 0.
>>
>> Upon doing some experiments, I believe that the first sentence in that
>> documentation is wrong.  It should say this instead:
>>
>>   If the receiver's retainCount is greater than 1, decrements it.  Otherwise,
>> invokes -dealloc.
>>
>> Reading the document Memory Management Programming Guide ▸ Object Ownership
>> and Disposal, one gets a similar false impression, although this document is
>> vague enough that it is only misleading, not wrong.
>>
>> OK, someone tell me why I'm wrong about this
>> :)
>
>

_______________________________________________

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

  • Follow-Ups:
    • Overriding -release to break retain cycle. Was: Doc for -release not quite true
      • From: Jerry Krinock <email@hidden>
References: 
 >Re: Documentation for -release is not quite true (From: "Gary L. Wade" <email@hidden>)

  • Prev by Date: Re: Documentation for -release is not quite true
  • Next by Date: Re: Documentation for -release is not quite true
  • Previous by thread: Re: Documentation for -release is not quite true
  • Next by thread: Overriding -release to break retain cycle. Was: Doc for -release not quite true
  • Index(es):
    • Date
    • Thread