[R] Should garbage collection be automatic in R sessions?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 30 20:06:38 CEST 2003

On Wed, 30 Jul 2003, Laurie Sindlinger wrote:

>    I am having problems with memory when running R on my PC.  I do not 
> have many large objects in my workspace, and yet when trying to create a 
> new vector I often encounter this error message:
> > lat <- header$lat[match(profile$id, header$id)]
>  Error: cannot allocate vector of size 4575 Kb
> Since it seems like this may indicate that I don't have enough memory
> available, I tried increasing nsize using mem.limits, but I still get
> this error message. 

See what ?mem.limits says about Windows ...  ?memory.size (and the 
rw-FAQ) may be more use to you.

> Is there a function in R where you can see the size
> of all objects in the workspace?

object.size(ls()), but not all objects using memory are in the workspace.

>   When I tried using gc(), I was then able to create the vector. It
> seems to indicate in the help pages that the garbage collection should
> happen automatically. Does anyone know how often this might take place
> or how I can check if it is occurring during my R sessions? Thanks for
> you help, and I have included info about my system below (I have 1 gbyte
> of memory).

?gcinfo, mentioned on ?mem.limits.

> Windows 2000

which is not the most efficient OS at using large amounts of memory 
(although better than Windows 9x).

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