• 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: memory problem, advice needed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory problem, advice needed


  • Subject: Re: memory problem, advice needed
  • From: Ondra Cada <email@hidden>
  • Date: Sat, 1 Apr 2006 17:03:28 +0200

Paul,

On 1.4.2006, at 15:53, Paul Gribble wrote:

Yes! This works of course. If I forego the convenience constructors and use
[[... alloc] initWith...] followed by a [... release]; at the end of myFun()
all is good in the world. Thanks all for reminding me of this.

Note that

(a) it is somewhat more error-prone, for by separating the allocation and releasing you increase the possibility of over/underrelease;
(b) if the code between may raise (or leave the scope prematurely in any other way), you should use an exception harness (and/or other means) to prevent leak in such a case (an autoreleased object won't leak, allocated and not-yet-released one of course would).
---
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
References: 
 >Re: memory problem, advice needed (From: Paul Gribble <email@hidden>)

  • Prev by Date: Re: cocoa app using external c++ code
  • Next by Date: Re: String memory leak
  • Previous by thread: Re: memory problem, advice needed
  • Next by thread: String memory leak
  • Index(es):
    • Date
    • Thread