You're closing your window, but that's not deallocating it because your window controller ModalWindowController
is still retaining it. I don't see anything in your sample to indicate the window controller is being released.
The simplest answer to give you is to have you release your window controller following your call to -runModalForWindow:
.
What you may be expecting is the window controller to close when your window does. That's something you have to make happen yourself. From "Window Closing Behavior," in Apple's documentation:
If you want the closing of a window to make both window and window controller go away when it isn’t part of a document, your subclass of NSWindowController can observe NSWindowWillCloseNotification or, as the window delegate, implement the windowWillClose: method and include the following line of code in your implementation: "[self autorelease];"
In your scenario, this might not be the best approach, because you'd wind up disposing of both your window controller and window before you get a chance to call -stopModal
.