Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory problem, advice needed



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: memory problem, advice needed (From: Paul Gribble <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.