From jmacdon at med.umich.edu  Wed Feb  8 17:37:38 2006
From: jmacdon at med.umich.edu (James MacDonald)
Date: Wed, 08 Feb 2006 11:37:38 -0500
Subject: [Rd] Using .onUnload() to unload compiled code
Message-ID: <s3e9d80e.049@med-gwia-02a.med.umich.edu>

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?

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.



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