MeetB
MeetB

Reputation: 61

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.

Upvotes: 6

Views: 2129

Answers (1)

anon
anon

Reputation:

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.

Upvotes: 5

Related Questions