[R] Rtemp directories accumulating over time

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 28 14:53:42 CEST 2004

On Tue, 27 Apr 2004 kjetil at acelerate.com wrote:

> There is a nuisance that the number of directories with name starting 
> Rtmp (and always empty) in my temp directory is increasing over time. 
> I put the following in my  .Rprofile:
> tmp0001 <- tempdir()
> setHook( packageEvent("base","onUnload"), 
>       function(...) unlink( tmp0001, recursive=TRUE) )
> which solves part of the problem, but not all. 

I don't see why: package base is never unloaded so that hook function is 
never run.  (Indeed, no package/namespace is unloaded except by 
explicit user action, in particular not when R is terminated.)

> So there are also other tmpdirs made by R. Why, where, and why are they
> not removed at exit (when their content are removed)?

They are removed by R.  This is a Windows-only bug, as Windows sometimes
does not act on commands to remove empty directories (but only sometimes).
Session temporary directories should only be left around when a session 

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-help mailing list