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

Carl Witthoft carl at witthoft.com
Tue May 3 01:40:41 CEST 2011


One more test: quite by accident, after typing

rm(foo)

I invoked the help function, i.e.

?matrix  (or ?anything_valid)

and R freed up most of the memory allocated to foo.   Hope this helps.


-------- Original Message --------
Subject: How to free up system memory?
Date: Mon, 02 May 2011 19:28:32 -0400
From: Carl Witthoft <carl at witthoft.com>
To: r-sig-mac at r-project.org <r-sig-mac at r-project.org>

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