So I was interested by this post and went and looked at the Mozilla source
some.

There seems to be no reason why after self-registering a DLL (shared
library, whatever) that that DLL can not be immediately unloaded out of
memory. It actually (from my brief foray into the code) looks like this was
the intention, but that it was not followed up on.

There is the canUnload( ) call in nsIModule which is used to make sure the
given DLL has no external references, this will allow that DLL to be
unloaded (if it has no outstanding references.) I traced around the code in
nsNativeComponentLoader.cpp and found the call to SelfRegisterDll( ) which
is called by all the auto-registration pieces.

The header for this method (with comments) is:

/*
 * SelfRegisterDll
 *
 * Given a dll abstraction, this will load, selfregister the dll and
 * unload the dll.
 *
 */
nsresult
nsNativeComponentLoader::SelfRegisterDll(nsDll *dll,
                                         const char *registryLocation,
                                         PRBool deferred)

But inside the code it does not actually unload the dll (though it does load
it and self-register it.)

So it is my belief that any DLL which is loaded by this at autoregister time
(which I think is any new/modified DLL, and any DLLs registered as being a
deferred component) will not be unloaded.

Maybe I'm not seeing the forest for the trees or something here...

Ken



Reply via email to