Matthew Keller
2010-Feb-06 02:24 UTC
[R] question about bigmemory: releasing RAM from a big.matrix that isn't used anymore
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? Thanks, Matt -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com
Steve Lianoglou
2010-Feb-06 04:27 UTC
[R] question about bigmemory: releasing RAM from a big.matrix that isn't used anymore
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
Jay Emerson
2010-Feb-06 21:44 UTC
[R] question about bigmemory: releasing RAM from a big.matrix that isn't used anymore
>>> See inline for responses. But people are always welcome to contact >>> us directly.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!>>> We strongly discourage use of dimnames.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?>>> It can take a while for the OS to free up memory, even after a gc(). >>> But it's available for re-use; if you want to be really sure, have alook>>> in /dev/shm to make sure the shared memory segments have been >>> deleted.Thanks, Matt -- John W. Emerson (Jay) Associate Professor of Statistics Department of Statistics Yale University http://www.stat.yale.edu/~jay <http://www.stat.yale.edu/%7Ejay> [[alternative HTML version deleted]]