Re: Am I overreleasing something?
Re: Am I overreleasing something?
- Subject: Re: Am I overreleasing something?
- From: Shawn Erickson <email@hidden>
- Date: Fri, 10 Jun 2005 12:55:36 -0700
On Jun 10, 2005, at 10:03 AM, Theodore H. Smith wrote:
I didn't quite mean it to that extreme, that would be silly. I meant more like this within my own code:
Obj = [[MyClass alloc] init]; [Obj doStuff]; [Obj release];
Actually doing the following...
Obj = [[[MyClass alloc] init] autorelease];[obj doStuff];
...can be safer and cleaner code wise (avoids exit point before your release causing a leak, etc.). I usually use autorelease unless I am worried about performance overhead or having a large object hang around longer then minimally needed.
If you are having problems using autorelease correctly you will have problems using release correctly (they aren't really that different). For tracking down bugs use ObjectAlloc.app (OmniGroup folks also have a good tool called OmniObjectMeter.app) and/or NSZombie functionality instead of changing away from potentially good coding practices.
-Shawn
|
_______________________________________________
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