views:

173

answers:

2

Should I somehow release shared object (on which singleton is based) when my application terminates if no garbage collector used (iPhone environment)?

+4  A: 

When an application exists all its memory is released. So it really does't matter if you release objects at all, so long as you don't use too much memory while running.

Even when the strategy changes in 4.0, a single small object won't have much impact; it will still be released along with the rest of the application when it terminates.

Paul Lynch
I'm sure I read somewhere that when an application knows it is going to close, it doesn't even bother doing the deallocs. Anyway, it is unnecessary to release singletons unless you are relying on dealloc to dispose of some external resource. If this is the case, redesign your class so you can explicitly dispose of the said external resource.
JeremyP
If you need to perform some sort of clean up when the application terminates, you can have the singleton object listen for `UIApplicationWillTerminateNotification`
Tom Dalling
A: 

As an aside, you might find this useful:

http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html

HZC
I've already read about implementing a singleton. I think my question is more narrow. Anyway, thank you.
kpower