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

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 8 19:30:46 CET 2006


On Wed, 8 Feb 2006, James MacDonald 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?

No. It is still needed whilst the namespace is loaded.  .onUnload is not 
run by detach(), but by unloadNamespace


>
> Best,
>
> Jim
>
>> search()
> [1] ".GlobalEnv"        "package:methods"   "package:stats"     "package:graphics"
> [5] "package:grDevices" "package:utils"     "package:datasets"  "Autoloads"
> [9] "package:base"
>
>> stats:::.onUnload
> function (libpath)
> library.dynam.unload("stats", libpath)
> <environment: namespace:stats>
>
>> getLoadedDLLs()
>                                                   Filename Dynamic.Lookup
> base                                                   base          FALSE
> iconv                        C:/rw2030dev/modules/iconv.dll           TRUE
> grDevices C:/rw2030dev/library/grDevices/libs/grDevices.dll          FALSE
> stats             C:/rw2030dev/library/stats/libs/stats.dll          FALSE
> methods       C:/rw2030dev/library/methods/libs/methods.dll          FALSE
>
>> detach(3)
>
>> search()
> [1] ".GlobalEnv"        "package:methods"   "package:graphics"  "package:grDevices"
> [5] "package:utils"     "package:datasets"  "Autoloads"         "package:base"
>
>> getLoadedDLLs()
>                                                   Filename Dynamic.Lookup
> base                                                   base          FALSE
> iconv                        C:/rw2030dev/modules/iconv.dll           TRUE
> grDevices C:/rw2030dev/library/grDevices/libs/grDevices.dll          FALSE
> stats             C:/rw2030dev/library/stats/libs/stats.dll          FALSE
> methods       C:/rw2030dev/library/methods/libs/methods.dll          FALSE
>
>> R.version
>               _
> platform       i386-pc-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
> status         Under development (unstable)
> major          2
> minor          3.0
> year           2006
> month          01
> day            01
> svn rev        36947
> language       R
> version.string Version 2.3.0 Under development (unstable) (2006-01-01 r36947)
>
>
> James W. MacDonald
> Affymetrix and cDNA Microarray Core
> University of Michigan Cancer Center
> 1500 E. Medical Center Drive
> 7410 CCGC
> Ann Arbor MI 48109
> 734-647-5623
>
>
>
> **********************************************************
> Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list