Releasing when closed?
Okay, this might boil down to personal preference but the use of singletons in this class bothers me somewhat. When the preference window is closed, the class and all those views are still sitting around in memory. This is especially bad when you have elaborate preferences, which in my case use a fair amount of memory.
If the singleton needs to stay, then perhaps there could be added a destruct method that will kill the singleton as well as its subviews. Not sure what the best way is to go about this. Ideas?
Hi, I had a similar issue. My app was experiencing random crashes after users opens the preferences window a few times. I suspect the singleton design is causing it. So, I am not using the class as a singleton anymore. I alloc and initialize it for every uses. Like this:
-(IBAction)showPreferences:(id)sender {
//activate app
[NSApp activateIgnoringOtherApps:YES];
//instantiate preferences window controller
if (_preferencesWindowController) {
[_preferencesWindowController release];
_preferencesWindowController = nil;
}
//init from nib but the real initialization happens in the
//PreferencesWindowController setupToolbar method
_preferencesWindowController = [[PreferencesWindowController alloc] initWithWindowNibName:@"Preferences"];
[_preferencesWindowController showWindow:self];
//[[PreferencesWindowController sharedPrefsWindowController] showWindow:self];
}
Hope that helps with your issue.