Re: Memory management question
Re: Memory management question
- Subject: Re: Memory management question
- From: Alastair Houghton <email@hidden>
- Date: Thu, 25 Mar 2004 09:32:33 +0000
On 24 Mar 2004, at 23:38, Ondra Cada wrote:
>
Alastair,
>
>
On Thursday, Mar 25, 2004, at 00:20 Europe/Prague, Alastair Houghton
>
wrote:
>
>
> id o = [[foo getter] retain];
>
> // code here
>
> // o used now
>
> [o release];
>
>
>
> which avoids an unnecessary autorelease :-)
>
>
... making the code also a possible leaker (which is not too
>
important), and *MUCH* more error-prone, which is generally *far far*
>
worse than the very slight autorelease overhead.
>
>
No, don't. This is generally a wrong pattern.
I think this probably also constitutes part of the same argument. I
would use -autorelease if the code might throw exceptions (because it
obviates the need for handlers) or if the code where you wrote that
comment was long (although if you have a lot of code there, there might
be opportunities for refactoring).
If I were worried about this level of risk of errors (IMO not that
high), I'd be using Ada and not a C derivative.
Kind regards,
Alastair.
--
http://www.alastairs-place.net
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.