Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releasing when closed? #3

Open
jwilling opened this issue Jun 25, 2012 · 1 comment
Open

Releasing when closed? #3

jwilling opened this issue Jun 25, 2012 · 1 comment

Comments

@jwilling
Copy link
Contributor

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?

@cherifya
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants