[R] question about bigmemory: releasing RAM from a big.matrix that isn't used anymore

Matthew Keller mckellercran at gmail.com
Sat Feb 6 20:37:03 CET 2010


Hi Steve and other R folks,

Thanks for the suggestion. No - that doesn't work. I meant to put that
into my original email. To recap

x <- big.matrix(nrow=20000,ncol=500000,type='short',init=0,dimnames=list(1:20000,1:500000))
#Gets around the 2^31 issue - yay!
#R takes 18 Gb RAM, so says top

rm(x)  #top says R still takes 18Gb RAM
gc()   #top says R still takes 18Gb RAM

How do I flush the memory? I thought maybe R/bigmemory would give up
the RAM if it was needed elsewhere, but apparently not:

y <- big.matrix(nrow=20000,ncol=500000,type='short',init=0,dimnames=list(1:20000,1:500000))
#takes *another* 18Gb RAM, and takes it away from several other
processes I had running - OUCH!

Any help would be appreciated.

As an aside, I just want to say "thank you" to the teams developing
bigmemory, ff, and other packages meant to allow users of large
datasets to still use R.

Matt



On Fri, Feb 5, 2010 at 9:27 PM, Steve Lianoglou
<mailinglist.honeypot at gmail.com> wrote:
> Hi,
>
> On Fri, Feb 5, 2010 at 9:24 PM, Matthew Keller <mckellercran at gmail.com> wrote:
>> Hi all,
>>
>> I'm on a Linux server with 48Gb RAM. I did the following:
>>
>> x <- big.matrix(nrow=20000,ncol=500000,type='short',init=0,dimnames=list(1:20000,1:500000))
>> #Gets around the 2^31 issue - yeah!
>>
>> in Unix, when I hit the "top" command, I see R is taking up about 18Gb
>> RAM, even though the object x is 0 bytes in R. That's fine: that's how
>> bigmemory is supposed to work I guess. My question is how do I return
>> that RAM to the system once I don't want to use x any more? E.g.,
>>
>> rm(x)
>>
>> then "top" in Unix, I expect that my RAM footprint is back ~0, but it
>> remains at 18Gb. How do I return RAM to the system?
>
> Maybe forcing R to do garbage collection might help?
>
> Try calling `gc()` after your call to `rm(x)` and see what `top` tells you.
>
> Did that do the trick?
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>



-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com



More information about the R-help mailing list