[Rd] Using .onUnload() to unload compiled code

Seth Falcon sfalcon at fhcrc.org
Wed Feb 8 19:13:01 CET 2006

Hi Jim,

On  8 Feb 2006, jmacdon at med.umich.edu wrote:
> If one wants to unload compiled code for a package containing a
> namespace, my understanding is that .onUnload() should be used, with
> a call to library.dynam.unload(). This is used in e.g., the stats
> and methods packages, but it appears to me that the compiled code is
> not being unloaded when the package is detached(). Am I
> misunderstanding something?

A package with a namespace can be loaded and not attached or loaded
and attached.

Use loadedNamespaces() to see what is loaded, and search() to see
what is attached.

.Last.lib() gets called by detach() is called.  .onUnload() is called
by unloadNamespace().  I'm pretty sure you can have both .Last.lib and
.onUnload in a package with a namespace.


+ seth

More information about the R-devel mailing list