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

Need to release "constant objects"?


  • Subject: Need to release "constant objects"?
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 04 May 2004 16:48:54 -0700

I use these things I call "constant objects", mostly strings, that I assign
to other variables, as needed, in a particular class. So, I declare them as
globals at the top of the file like this (I show NSNumbers instead of
NSStrings as examples because the shorter lines fit better in email):

static NSNumber* objectTrue;
static NSNumber* objectFalse;

then I create them in my class's -init method:

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.

Jerry Krinock
San Jose CA USA
_______________________________________________
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.


  • Follow-Ups:
    • Re: Need to release "constant objects"?
      • From: Eric Wang <email@hidden>
    • Re: Need to release "constant objects"?
      • From: Julien Dufour <email@hidden>
    • Re: Need to release "constant objects"?
      • From: Larry Fransson <email@hidden>
    • Re: Need to release "constant objects"?
      • From: cricket <email@hidden>
  • Prev by Date: NSConnection and independant queuing
  • Next by Date: Is NSAppleScript thread-safe?
  • Previous by thread: Re: NSConnection and independant queuing
  • Next by thread: Re: Need to release "constant objects"?
  • Index(es):
    • Date
    • Thread