Re: Re(2): Strange crash, CFBundle*
Re: Re(2): Strange crash, CFBundle*
- Subject: Re: Re(2): Strange crash, CFBundle*
- From: Douglas Davidson <email@hidden>
- Date: Tue, 11 Dec 2001 12:03:21 -0800
On Tuesday, December 11, 2001, at 11:23 AM, Dan Wood wrote:
Douglas, is this also the case with NSBundles? I'm currently working
on a problem where I'm trying to completely deallocate an NSBundle
(because the version on disk has been updated to a new version), and
then load it again. Maybe this "unique-ing" is getting in the way.
Any way to cause a bundle to be re-fetched from disk?
NSBundle does not support unloading, because there is not sufficient
support in the Objective-C runtime to truly allow bundles to be
unloaded. CFBundle does support unloading, provided that the underlying
executable is of a kind that can be unloaded--for example, the main
executable and Mach-o frameworks cannot be unloaded, but CFM plug-ins
and Mach-o bundles can be unloaded.
If all references to an unloadable CFBundle are released, the bundle
will be unloaded; there is also an API, CFBundleUnloadExecutable, which
will immediately unload an unloadable bundle regardless of whether there
are references to it or not, but you use it at your own risk. In any
case, you must make sure that there are no outstanding pointers to
symbols within a bundle before it is unloaded; at a minimum, any code
that has such a pointer should maintain a reference to the bundle.
CFPlugIn has its own reference-counting scheme for instances, and if a
CFPlugIn has no outstanding instances, and is dynamically loadable, then
it will be unloaded--not immediately, but soon thereafter.
Douglas Davidson