Re: Need to release "constant objects"?
Re: Need to release "constant objects"?
- Subject: Re: Need to release "constant objects"?
- From: Larry Fransson <email@hidden>
- Date: Tue, 4 May 2004 23:33:36 -0700
On May 4, 2004, at 16:48, Jerry Krinock wrote:
objectTrue = [[NSNumber alloc] initWithBool:TRUE] ;
objectFalse = [[NSNumber alloc] initWithBool:FALSE] ;
and then I just assign to other variables whenever needed.
I never bother to release them, because I need them as long as the
program
is running. I was wondering, however, when I run "leaks" from the
command
line, do these show up as leaks and, if so, is there a better idiom?
I like
to see no warnings and no leaks.
The big hint here is the "alloc". If you "alloc" it, you have to
release it. it will not, however, show up as a leak until those
variables go out of scope. So if they're global, they never go out of
scope until the object they're members of is released and dealloced.
If they're not released by that time, they will be leaked.
Larry Fransson
Seattle, WA
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.