• 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: Ondra Cada <email@hidden>
  • Date: Sat, 18 Mar 2006 13:55:06 +0100

Karim,

On 18.3.2006, at 12:54, Karim Morsy wrote:

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 ?

If you insist to know, override retain in your class, put a breakpoint there, and launch the app in gdb: you'll see exactly who and where retains it.


(There most probably will be considerably more than three retains, but only three not balanced by a release.)

Oh, incidentally, since you are self-evidently learning...

... 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.

I respectfully disagree with j o a r in this: in my opinion, writing deallocs brings hardly any benefit unless you really need them. And the time spared by not writing them for classes whose instances are never deallocated anyway you can invest in a much better way :)


The most I would do in such a case myself (most often not even that!) would be something like

-(void)dealloc {
NSLog(@"### WARNING: %@ at 0x%x is being dealloc'd which should never happen! Breakpoint %s:%d to find the cause",[self class],self,__FILE__,__LINE__);
}


(Note: I would refrain from logging self through %@ in such a case, for God only knows what at the moment -description might cause.)
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc



_______________________________________________ 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: j o a r <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>)
 >Re: which cocoa objects to dealloc ? (From: Karim Morsy <email@hidden>)

  • Prev by Date: Re: exceptions, threads & NSLock
  • Next by Date: Re: which cocoa objects to dealloc ?
  • Previous by thread: Re: which cocoa objects to dealloc ?
  • Next by thread: Re: which cocoa objects to dealloc ?
  • Index(es):
    • Date
    • Thread