[cfe-dev] Missing dealloc analysis

Ted Kremenek kremenek at apple.com
Thu Jul 3 10:42:39 PDT 2008

On Jul 3, 2008, at 10:30 AM, David Chisnall wrote:

> This is especially true when you consider subclassing.  A singleton  
> can not guarantee that its subclasses will also be singletons, and  
> so should release all of its ivars when it is -dealloc'd, or risk  
> causing leaks if it is subclassed.

I think the current logic in the checker handles this.  The check is  
obviated for a class if it doesn't contain any ivars, but the check is  
applied to every class, including subclasses of classes that didn't  
contain ivars.  Consequently, it should handle the case where  
singletons are subclassed.

> If a singleton needs to have shared resources that are also shared  
> with subclasses then it should store them in file statics, no ivars.

Right.  That's how I thought the Singleton pattern was typically  

More information about the cfe-dev mailing list