CFBundleCreate() problem in OSX 10.5


    Sep 06 2008 | 10:42 pm
    This is a fun one -- I don't know if anyone has the answer, but
    hopefully someone here has better knowledge of how Apple is handling
    dynamic-loading.
    I'm loading executable code from a bundle, and in 10.4 it loaded
    "cleanly"; i.e. each instance seemingly had a unique data space
    context associated with it.
    What I am doing is getting the bundle via CFBundleCreate(), then I
    load the executable code with CFBundleLoadExecutable() (I do an
    unload if the bundle had been loaded previously). But it seems that
    subsequent loads of the code are pointing to the same Bundle ref in
    memory.
    The Apple docs say this about CFBundleCreate():
    "Once a bundle has been created, it is cached; the bundle cache is
    flushed only periodically. CFBundleCreate does not check that a cached
    bundle still exists in the filesystem. If a bundle is deleted from the
    filesystem, it is therefore possible for CFBundleCreate to return a
    cached bundle that has actually been deleted."
    and I suspect this may be causing the problem. The docs also say this
    about CFBundleCreate():
    "May return an existing CFBundle object with the reference count
    incremented."
    Does anyone know if there is a way to flush the cache or zero the
    reference count on CFBundle objects?
    brad