Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close NSWindow and release memory, but re-open it on a button click

I have a requirement in which I need to show same window after some time. So i have achieved it using [window setReleaseWhenClose:NO] , but now the problem is that it keeps occupying 2MB of memory.

I want to have it like this that when i open it it uses 2MB of memory and when i close it it frees that memory, but still I should be able to re-open it.

If u have got any clues, that would be helpful.

Thanks

M.B.

like image 506
MeetB Avatar asked Jan 04 '11 07:01

MeetB


1 Answers

If you want the memory to be released you have to release the window after it gets closed. If you need it again you always can reload the nib file. There is no way to keep the window loaded and release the memory at the same time.

To make this memory management easier you should use a NSWindowController to manage the memory.

But I wouldn’t worry about 2 MiB of RAM. Keeping the window in memory might be preferable to loading it again when it’s needed.

like image 146
Sven Avatar answered Oct 18 '22 22:10

Sven