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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 08 Feb 2006 - 18:30:46 GMT

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@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu Feb 09 07:23:15 2006

This archive was generated by hypermail 2.1.8 : Fri 10 Feb 2006 - 02:15:50 GMT