Close NSWindow and release the memory, but reopen it by pressing the button

I have a requirement in which I need to show the same window after a while. So I achieved this with [window setReleaseWhenClose:NO] , but now the problem is that it takes up 2 MB of memory.

I want it to be so that when I open it, it uses 2 MB of memory, and when I close it, it frees this memory, but still I have to open it again.

If you have any clues this would be helpful.

thanks

MB

+6
objective-c cocoa macos nswindow
source share
1 answer

If you want the memory to be released, you need to free the window after closing. If you need it again, you can always reload the nib file. Unable to save window and release memory at the same time.

To simplify memory management, you should use NSWindowController to manage memory.

But I would not worry about 2 megabytes of RAM. Storing a window in memory may be preferable to reloading it when necessary.

+5
source share

All Articles