Who should release whom in a document-based app?
Who should release whom in a document-based app?
- Subject: Who should release whom in a document-based app?
- From: Rick Hoge <email@hidden>
- Date: Tue, 27 Jul 2004 21:52:12 -0400
I'm trying to debug a memory leak in a document-based app.
In addition to my NSDocument subclass, I have an NSWindowController
subclass that is the owner of the document's nib file and the delegate
of the document window.
When I close the document window, neither the window controller nor the
document are getting the dealloc message. I respond to windowWillClose
in the window controller, and note that the retain count of both the
document and the window controller are unexpectedly high (3 for the
doc, 8 for the window controller). I have a number of custom views in
the document nib file and these do not get the dealloc message either.
This is somewhat complicated by the fact that there are Cocoa bindings
to the window controller in the nib file. However I am trying to
figure out what the canonical sequence of events is on window closure
(my window is set to release when closed), realizing I'm not sure what
this is.
When the window is closed, does this release the window controller
which then releases the document? In what methods do the final
'release' messages get sent? Is there anything that I need to code
manually for this all to happen, or is all done automatically? If
there are bindings in the nib file, do I need to add code to clear the
observers?
Any tips on how this should work (or rtfm suggestions), as well as on
how to debug reference count imbalances would be appreciated!
Rick
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.