Re: Newbie question: how to release an object that has been autoreleased
Re: Newbie question: how to release an object that has been autoreleased
- Subject: Re: Newbie question: how to release an object that has been autoreleased
- From: Ondra Cada <email@hidden>
- Date: Wed, 22 Sep 2004 14:16:16 +0200
Uh, sorry, but I beg to differ: IMHO, the following pattern is not that
good.
On 22.9.2004, at 9:29, mmalcolm crawford wrote:
Buffer *bufferFromPool = [Buffer newBufferFromPool];
// ...
[bufferFromPool release];
? No autorelease "issues," and more efficient.
Also considerably more prone to programmer's errors of the new/release
mismatch kind, which is pretty bad. And also prone to leak if an
exception is raised. The former problem is impossible to sure; since
the latter, the complete pattern is rather
Buffer *bp=[Buffer newBufferFromPool];
NS_DURING
// ...
NS_HANDLER
[bp release];
[localException raise];
NS_ENDHANDLER
[bp release];
(or some equivalent, perhaps with @try) which still *might* be
*somewhat* more efficient, but in a vast majority of cases definitely
is not worth the hassle. That is, unless you are *completely* sure the
'//...' code never ever raises, but save for some extremely plain C
computations that is rarely the case.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden