Re: Hillegass book memory question
Re: Hillegass book memory question
- Subject: Re: Hillegass book memory question
- From: Uli Kusterer <email@hidden>
- Date: Tue, 3 Jun 2008 10:09:29 +0200
Am 03.06.2008 um 07:10 schrieb Adam Leonard:
The Cocoa frameworks take this shortcut, as do most applications.
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:.
But as others have said, it's OK. The OS will reclaim all memory an
app has used when it has quit, so there's no need to release objects
that are singletons used throughout the app's life. Though I usually
add a comment next to such lines: "// intentional 'leak': singleton."
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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