Re: __attribute__ ((destructor)) functions vs static global variables
Re: __attribute__ ((destructor)) functions vs static global variables
- Subject: Re: __attribute__ ((destructor)) functions vs static global variables
- From: Markus Hitter <email@hidden>
- Date: Thu, 4 Aug 2005 23:48:29 +0200
Jesper,
thought I'd share some of my limited knowledge ...
Am 04.08.2005 um 18:59 schrieb Jesper Papmehl:
My guess is that the runtime code is destructing static data before
calling the "bundle destructor".
Apps on Mac OS X don't care about destructing data, AFAIK. They
simply quit and mark the memory as free. At least, the -dealloc
method of Cocoa objects isn't sent if the object has a lifetime until
the app's end.
Is there any way to control this behavior?
Do your work from some higher level, e.g. the Quit menu handler. An
alternative might be atexit(3).
The reason I need this: In our class library, we have a mechanism
to register functions that should be called when the current code
module "exits". For an app, that is when the app quits. For a
loadable bundle (and frameworks), that is when the bundle is unloaded.
It's news to me dylibs (frameworks, plugins) can be unloaded at all
without quitting the app.
(When building with CodeWarrior, this isn't a problem, mainly
because you have to destroy statics yourself by calling
__destroy_global_chain(), and then you have control over exactly
when it is done.)
Yeah, CodeWarriors have no fear to dive deep into runtime stuff :-)
If you have some code which attempts to unload your module, you have
a hook to unregister your functions as well, don't you?
Again, that's only my $0.02. Hope it's helpful anyways.
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden