[R-SIG-Mac] How to free up system memory?

Carl Witthoft carl at witthoft.com
Tue May 3 01:28:32 CEST 2011


I'm not sure exactly what's happening, so I'll try to describe the steps 
in detail.  I get the same behavior with R 2.12.1 and R 2.13, OSX 10.6.6 
or 10.6.4 .

First, I boot up Activity Monitor and set it to show memory usage.

I create a large object (in the R Console of R.app GUI) , such as

foo<-runif(1e8)

and the "real memory" in the table and "active memory" in the pie chart 
go up.  No surprise.

Then I get rid of foo,

rm(foo)

But the memory allocations don't change.   Looks like a memory leak?

Two other things I found:

1) If I write a function that does nothing but create some big objects 
like that, and then deletes them,  ActivityMonitor shows memory 
allocated to R and then freed up.  This is what I'd expect from the 
R.app GUI as well.

2) If I boot several other applications, using up all my RAM, at some 
point the operating system moves some of R's active memory into virtual 
memory.  Now the funny thing:  if I make R the foreground app, or if I 
simply quit all the other apps,  R does not get its active memory 
allocation back.  The 'pie chart' shows memory has been freed, not just 
"inactive" .

Did I set some bad parameter in one of my config files?  Is there some 
way within R to force all that memory to be freed up (other than 
quitting and restarting R)?

Thanks for your help -- I'm not the least put out if someone wants to 
point out what a dummy I'm being.

Carl



More information about the R-SIG-Mac mailing list