Re: Objective C++ memory management
Re: Objective C++ memory management
- Subject: Re: Objective C++ memory management
- From: "Joshua D. Orr" <email@hidden>
- Date: Tue, 1 Nov 2005 17:48:38 -0700
If you use a Document-Based Cococa app, the NSDocumentController I
think is the one that will release the objects when the document is
closed. Otherwise, you will have to load in the .nib file your self
somewhere and then you can release it your self after it's not used
anymore.
In this case, NSDocumentController will make an instance of an object
you specify (a document object that I think if I remember correctly
needs to inherit from NSDocument) and that object should give the
name of the .nib file to load in (it gives it to it's super class,
NSDocument, and code in NSDocument loads in the nib file). It will
keep making instances of a .nib file every time a new instance of
your document object is created (one should be for every document
open), and it should not be the main nib file that keeps being used
for this (the one that has the applications global menu bar in it),
it should be a different nib file.
On Nov 1, 2005, at 3:39 PM, Garvin Haslett wrote:
On 1 Nov 2005, at 18:51, Nick Zitzmann wrote:
On Nov 1, 2005, at 11:00 AM, Garvin Haslett wrote:
You are correct, which leaves me mystified. I thought that Cmd-Q
or clicking the red button on the window would automatically
force a call to dealloc. Clearly this is not the case. Can
anyone clear up my confusion.
Top level objects in the main nib file aren't deallocated when the
program quits. You generally don't need to worry about
deallocating objects when the application quits, because the
memory is going to be freed anyway. If you need to do something
before the application quits, then you should use the
NSApplication delegate method -applicationWillTerminate:.
Nick Zitzmann
<http://www.chronosnet.com/>
Ok, in this case I don't have a problem, this is only a single
window application with a single QuartzView in that window.
Now, i'm imagining a problem for the future: What happens if I
create a new version which allows the user to open and close
multiple windows via the Menuba. Each one of these windows will
own a QuartzView and therefore each one will allocate their own
BitMapMgr. Will this scenario lead to a lot of leaks or are the
windows managed differently in this scenario?
Garvin.
___________________________________________________________ How
much free photo storage do you get? Store your holiday snaps for
FREE with Yahoo! Photos http://uk.photos.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40xmission.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden