• 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: Newbie question: how to release an object that has been autoreleased
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Newbie question: how to release an object that has been autoreleased
      • From: James Bucanek <email@hidden>
References: 
 >Newbie question: how to release an object that has been autoreleased (From: James Bucanek <email@hidden>)
 >Re: Newbie question: how to release an object that has been autoreleased (From: Scott Stevenson <email@hidden>)
 >Re: Newbie question: how to release an object that has been autoreleased (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Scripting support problems
  • Next by Date: NSTimer questions
  • Previous by thread: Re: Newbie question: how to release an object that has been autoreleased
  • Next by thread: Re: Newbie question: how to release an object that has been autoreleased
  • Index(es):
    • Date
    • Thread