[R] R not giving memory back to system?

Thomas Lumley tlumley at u.washington.edu
Mon Nov 26 23:51:16 CET 2001


On Mon, 26 Nov 2001, Gardar Johannesson wrote:

> This might be because I didn't get it right, but; I thought R would
> release memory back to the system as (big) objects get removed?
>

You can give it back, but you can't force the OS to take it. This is from
the comp.lang.c newsgroup's FAQ (http://www.eskimo.com/~scs/C-faq/top.html)
---
Question 7.25
I have a program which mallocs and later frees a lot of memory, but memory
usage (as reported by ps) doesn't seem to go back down.
A: Most implementations of malloc/free do not return freed memory to the
operating system (if there is one), but merely make it available for
future malloc calls within the same program.
----

On the other hand, if the space isn't being used by R it will be paged out
to virtual memory after a while, so it doesn't really matter whether it's
reclaimed (unless you are very short on virtual memory).


	-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