[R] Garbage collection: RW1041

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Apr 29 21:52:24 CEST 2002


Laurens Leerink wrote:
> 
> Have searched through the archives but have been unable to find any related
> issues - hopefully I'm not bringing up an old topic.
> 
> Am using RW1041 on a Windows NT on a machine with 1Gb of memory.  Have a
> function doit() that reads in a chunk of data using readBin, performs a
> regression, saves out coeffs and then returns.  When using Rgui with the
> default memory limit of 256Mb I'm able to call this function twice before
> running out of memory. After the allocation fails the GC is called & everything
> is freed, ie we end up with the same memory as before.  Here is an example:
>
> > gc()
>          used (Mb) gc trigger (Mb)
> Ncells 217415  5.9     467875 12.5
> Vcells  63668  0.5     786432  6.0
> > doit()
> > gc()
>           used (Mb) gc trigger  (Mb)
> Ncells  342932  9.2     667722  17.9
> Vcells 7966401 60.8   14760173 112.7
> > doit()
> > gc()
>            used  (Mb) gc trigger  (Mb)
> Ncells   468373  12.6     818163  21.9
> Vcells 15869121 121.1   22798845 174.0
> > doit()
> Error: cannot allocate vector of size 3750 Kb
> In addition: Warning message:
> Reached total allocation of 256Mb: see help(memory.size)
> > gc()
>          used (Mb) gc trigger  (Mb)
> Ncells 217515  5.9     787219  21.1
> Vcells  63724  0.5   23990430 183.1
> >
> 
> Have increased memory size to 768Mb, but it just takes a few more iterations to
> fail.  Got excited after reading the gctorture() documentation, so inserted a
> few lines
> 
>     gctorture(on = TRUE)
>     allocate some memory
>     gctorture(on = FALSE)
> 
> hoping to trigger a GC but with varied success - the Vcell usage drops but only
> slightly, so we seem to trigger a partial GC.  Usually fails on the next call
> to "doit".
> 
> Have messed around with a few other cheats, eg using gc() to determine where
> the trigger level is, then allocating and then deleting object(s) [one large
> object or several smaller ones] so that we end up above the trigger level but
> below the memory limits - limited success but nothing beyond adding one or two
> more iterations.
> 
> Any advice/tips/cheats would be appreciated.


This bug is known (I guess) and was discussed in a thread regarding 
   Subject: Re: [Rd] Memory "leak" in readChar (PR#1483)
on R-devel today. 

A partial fix for [from the News file:]
    o readChar() was not resetting vmax, so causing memory build-up.
      (PR#1483)
is already in R-1.5.0.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list