[R] features of save and save.image (unexpected file sizes)

Professor Brian Ripley ripley at stats.ox.ac.uk
Wed Jan 31 19:06:04 CET 2007


Two comments:

1) ls() does not list all the objects: it has all.names argument.

2) save.image() does not just save the objects in the workspace, it also
saves any environments they may have.  Having a function with a
large environment is the usual cause of a large saved image.

(And finally, a compressed binary representation from save.image is
nor comparable sizewise with an ASCII version from dump.)

Vaidotas Zemlys wrote:
> Hi,
> 
> Today I came upon unexpected R behaviour. I did some modelling and the
> result was R object,  about 28MB size (nested list, with matrixes as
> list elements). When I was saving the session with save.image, the
> resulting .RData file was 300MB. There were no other large objects:
> 
>> sum(sapply(ls(),function(x)eval(parse(text=paste("object.size(",x,")",sep=""))))/1024^2)
> [1] 30.10540
> 
> The interesting thing, then I removed the large object with rm,
> save.image again produced  .RData file with 300MB size. Only after
> rm(list=ls()) I got normal sized .RData file. I used dump for dumping
> my object, the resulting dump file was 72 MB in size. So I assume that
> R was saving some large object which was not visible to me directly,
> using ls(). Is there a way to find such objects, and discard them
> before saving? I use R 2.4.1 on Ubuntu 6.06, through Emacs 23.0 and
> ESS 5.3.1.
> 
> Vaidotas Zemlys
> --
> Doctorate student, http://www.mif.vu.lt/katedros/eka/katedra/zemlys.php
> Vilnius University

-- 
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