When a NSWindow or NSPanel is closed by clicking the red button, is it fully removed from memory?
I am working on some Cocoa exercise for beginners. Asking this because applications like iTunes do not really terminate when their red buttons开发者_运维问答 are clicked. I have a NSPanel object with the "release when close" option checked. An IBOutlet variable is set up to point to the NSPanel object using IB. When the NSPanel object is closed by the red button, the pointer variable is assigned "nil" by a delegate method. When the pointer is "nil", the user could load the NSPanel's nib file again (using loadNibName indirectly) and redisplay the panel.
My question is : if the NSPanel object is not fully removed when closed then would memory be wasted when the NSPanel's nib file is being loaded the second time ? (since the panel is an "About Panel" and there should only be one such window on display. And its nib file is being loaded twice...)
As pointed out by ughoavgfhw, the "release when close" option when chosen will cause the panel to be removed from memory. So we do not really have to worry about loading the nib file multiple times. But I suspect that letting the panel stay in memory when closed would improve respond time since the nib file will not need to be reloaded. However, it may cause some extra memory used. In practice, response time on my Mac mini 2.4 GHz Core 2 Duo in this case is not an issue at all. The display time of the about panel is instantaneous even when the nib file has to be loaded every time. It may be an issue on iPhone though...
精彩评论