• 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
globals and memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

globals and memory leaks


  • Subject: globals and memory leaks
  • From: Francisco Tolmasky <email@hidden>
  • Date: Sun, 20 Apr 2003 13:43:25 -0700

In my program I frequently do something like this:

static NSImage * someImage;

@implementation myClass

+ (void)initialize
{
someImage= [[NSImage imageNamed: @"Some Image"] retain];
}

//...

@end

Firstly, is this the correct way to do this. Secondly, if it is, should I be worried about memory leaks, do I have to release this image when the program terminates?

I also do this with my shared Instances, like this:

Prefernces * sharedPrefs;

@implementation Preferences

+ (void)sharedInstance
{
if(!sharedPrefs) sharedPrefs= [[Preferences alloc] init];
return sharedPrefs;
}

Do I ever release sharedPrefs??

Thank you in advance,

Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
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: globals and memory leaks
      • From: publiclook <email@hidden>
    • Re: globals and memory leaks
      • From: David Remahl <email@hidden>
  • Prev by Date: NSPropertyListSerialization woes
  • Next by Date: Re: globals and memory leaks
  • Previous by thread: NSPropertyListSerialization woes
  • Next by thread: Re: globals and memory leaks
  • Index(es):
    • Date
    • Thread