• 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: Need to release "constant objects"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Need to release "constant objects"? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: ANN: New Binary Installers for GSWeb and GDL2
  • Next by Date: The Cell from Hell (TM)
  • Previous by thread: Re: Need to release "constant objects"?
  • Next by thread: Re: Need to release "constant objects"?
  • Index(es):
    • Date
    • Thread