• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hillegass book memory question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Hillegass book memory question
      • From: Randall Meadows <email@hidden>
References: 
 >Hillegass book memory question (From: Ashley Perrien <email@hidden>)
 >Re: Hillegass book memory question (From: Adam Leonard <email@hidden>)

  • Prev by Date: Re: Drag-to-poof and tables
  • Next by Date: Re: NSPredicate: To be, or not to be
  • Previous by thread: Re: Hillegass book memory question
  • Next by thread: Re: Hillegass book memory question
  • Index(es):
    • Date
    • Thread