globals and memory leaks
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.