[R] 1.2.2 under M$ windows 2000 lots of plots out of memory?

Thomas Lumley tlumley at u.washington.edu
Mon Mar 12 18:43:46 CET 2001


On Mon, 12 Mar 2001, Bob Sandefur wrote:

> hi-
>  If I source the following
>
> for(k in seq(1:20)){
> x<-runif(20000,min=-500,max=2000)
> y<-runif(20000,min=-500,max=2500)
> z<-runif(20000,min=-10,max=10)
> cat(k,"file",memory.size())
> cc<-rainbow(11)
> plot(x,y,asp=1i,xlim=c(-500,2000),ylim=c(-500,2500),main=k,cex=1.0)
> for(i in seq(-10,10,2)){
>  points(x[z > i],y[z > i],col=cc[(12+i)/2],cex=1.0)
>  }
> rm(x,y,z)
> cat(k,"fil2",memory.size(),"\n")
> #readline(prompt="enter for nextplot")
> dev.off()
> }
> ~
>
>  the check print gets to 256MB and R fails; I think I am freeing everthing with the rm(...) and dev.off().
> Am I failing to free something or force  r to do garbage collection?
>
> I start r with
>
> P:\r\base\rw1022\bin\rgui.exe --vsize=300M --nsize=20000k
> and turn of buffered output

Well, that's the problem. You are asking R to allocate 300Mb of heap and
20 million cons cells (at 28 bytes each) at startup, for a total of about
800Mb of memory.  This means there's no need for garbage collection until
you reach 800Mb of memory. If you don't have 800Mb of memory it isn't
surprising that this doesn't work well.


Under NT with R1.2.0 the memory grows without any garbage collection if I
specify a huge memory size as you did.  If I don't, the memory stays at
about 12Mb.  There is a slight increase of about 2k on each iteration, but
this would probably be garbage collected when it got big.

Under R1.2 and more recently you don't have to specify memory size; R can
allocate dynamically. You can specify minimum and maximum sizes, and if
you use the old --vsize notation you are specifying the minimum.  The only
real need for specifying memory nowadays is to stop R taking over the
computer: you can specify maximum sizes that are enough smaller than the
physical memory to make sure other processes can run.



	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

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