• 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: which cocoa objects to dealloc ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: which cocoa objects to dealloc ?


  • Subject: Re: which cocoa objects to dealloc ?
  • From: Karim Morsy <email@hidden>
  • Date: Sat, 18 Mar 2006 12:54:32 +0100

thanks for that info!

I'm curious though about why the retain count of the app controller is 3 and not 1 ... all I do is instantiate it in IB, I never retain it explicitly.
any ideas ?


Karim



On Mar 18, 2006, at 12:13 PM, j o a r wrote:


On 18 mar 2006, at 12.04, Karim Morsy wrote:

Cocoa will skip over sending deallocation messages to objects when your app is about to quit.

so it doesn't really make any sense to override dealloc in an app controller and release any of the allocated memory, such as for NSString, nsarray or custom obejcts etc.., right ?

For objects that you intend to keep around for the duration of the application lifetime (typically using the "singleton" design pattern) there is little reason to implement dealloc. That said, I would still strongly suggest that you do, because it's a good habit to get into! I always dutifully implement correct dealloc methods in all classes.


This is an optimization, as all memory will be reclaimed by the OS after the app has terminated in any case.

i see, so memory leaks can only occur during runtime and never after an app has terminated, be it normally or due to a chrash ?

Exactly. Memory wise, your application is living in a "box" that the OS provides for it. When the app quits, the OS reclaims the entire box of memory. Your app is not allowed to allocate memory outside of this box, and so can't generate memory leaks after it's terminated - regardless of it's a controlled termination or a crash.



j o a r



_______________________________________________ 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
  • Follow-Ups:
    • Re: which cocoa objects to dealloc ?
      • From: Markus Hitter <email@hidden>
    • Re: which cocoa objects to dealloc ?
      • From: Ondra Cada <email@hidden>
References: 
 >which cocoa objects to dealloc ? (From: Karim Morsy <email@hidden>)
 >Re: which cocoa objects to dealloc ? (From: j o a r <email@hidden>)
 >Re: which cocoa objects to dealloc ? (From: Karim Morsy <email@hidden>)
 >Re: which cocoa objects to dealloc ? (From: j o a r <email@hidden>)

  • Prev by Date: Re: which cocoa objects to dealloc ?
  • Next by Date: Re: Using LDAP framework with SSL
  • Previous by thread: Re: which cocoa objects to dealloc ?
  • Next by thread: Re: which cocoa objects to dealloc ?
  • Index(es):
    • Date
    • Thread