• 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: Automagic instantiation of singletons?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automagic instantiation of singletons?


  • Subject: Re: Automagic instantiation of singletons?
  • From: Scott Ribe <email@hidden>
  • Date: Wed, 23 Nov 2005 08:06:13 -0700
  • Thread-topic: Automagic instantiation of singletons?

> For example, if you message an Objective-C class in
> a C++ static constructor, and the corresponding method creates an
> autoreleased object, it will be leaked and (logged as such) since it
> was created without any autorelease pool in place.

And there are worse examples than just never releasing a singleton (after
all, if it doesn't need to do any explicit cleanup beyond releasing memory
or closing files, it doesn't really matter). Suppose that a Cocoa instance
is allocated in a C++ static constructor, and is released in the destructor
after Cocoa is "finished" to some degree. Releasing that object might
reference a no longer existent NSNotificationCenter, indirectly through some
hard-to-trace dependencies set up behind the scenes by the Cocoa framework,
and give you a crash on close. Believe me, I'm pretty sure that can happen
;-)

--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 665-7007 voice


 _______________________________________________
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

References: 
 >Re: Automagic instantiation of singletons? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Custom NSView in IB palette
  • Next by Date: Re: About RTF and Arial
  • Previous by thread: Re: Automagic instantiation of singletons?
  • Next by thread: Re: Automagic instantiation of singletons? (Christian Brunschen)
  • Index(es):
    • Date
    • Thread