Re: Automagic instantiation of singletons?
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