Re: Hillegass book memory question
Re: Hillegass book memory question
- Subject: Re: Hillegass book memory question
- From: Randall Meadows <email@hidden>
- Date: Tue, 3 Jun 2008 08:39:29 -0600
On Jun 3, 2008, at 2:09 AM, Uli Kusterer wrote:
Am 03.06.2008 um 07:10 schrieb Adam Leonard:
By the way, this shortcut is not just the result of laziness, it is
actually faster. Instead of going through all the objects that are
used throughout the life span of the app, and having the OS free
all of them one at a time, the shortcut lets the OS group all these
objects and free them at the same time.
It is, however, perfectly acceptable to override -dealloc in
AppController and call [speachSynthesizer release]. I am sure this
is discussed elsewhere in the book.
It's not quite that easy: As your first line says, the Cocoa
frameworks also take that shortcut. This includes NSApplication,
which doesn't release its MainMenu.nib, and instead just relies on
the OS to do that when it cleans up the app's whole memory space
after it has quit.
So, your app delegate's -dealloc never gets called.
If you really wanted to get rid of this object before quitting,
you'd have to do so in -applicationWillTerminate:.
And you'll need to do things this way if you have other resources that
you need to clean up; in my case, I needed to cleanly disconnect from
a peripheral before quitting, and -applicationWillTerminate: seemed to
be the only place where that worked reliably.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden