Dear R-helpers, I am running R version 2.9.1 on a Mac Quad with 32Gb of RAM running Mac OS X version 10.5.6. With over 20Gb of RAM "free" (according to the Activity Monitor) the following happens. > x <- matrix(rep(0, 6600^2), ncol = 6600) # So far so good. But I need 3 matrices of this size. > y <- matrix(rep(0, 6600^2), ncol = 6600) R(3219) malloc: *** mmap(size=348483584) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug R(3219) malloc: *** mmap(size=348483584) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Error: cannot allocate vector of size 332.3 Mb Now a 6600 x 6600 matrix should take up less than 400Mb of RAM. So the question is, with 20Gb of RAM free how come I can't create more than one matrix of this size? (In fact, sometimes R won't even create one of them.) More to the point, is there some simple remedy? (Rewriting all my code to use the "Matrix" library, for example, is not a simple remedy.) I tried launching R in a terminal with R --min-vsize=10M --max-vsize=5G --min-nsize=500k --max-nsize=900M and that didn't work either. Finally, let me remark that I had the same problem with an older version of R. -- Steve Ellis
Jonathan Greenberg
2009-Jul-01 20:40 UTC
[R] "Error: cannot allocate vector of size 332.3 Mb"
Steve: Are you running R64.app? If not, grab it from here: http://r.research.att.com/R-2.9.0.pkg (http://r.research.att.com/ under "Leopard build") . As far as I know (and I actually just tried it this morning), the standard R 2.9.1 package off the CRAN website is the 32 bit version, so you won't be able to access > 4GB of RAM. --j Steve Ellis wrote:> Dear R-helpers, > > I am running R version 2.9.1 on a Mac Quad with 32Gb of RAM running > Mac OS X version 10.5.6. With over 20Gb of RAM "free" (according to > the Activity Monitor) the following happens. > > > x <- matrix(rep(0, 6600^2), ncol = 6600) > > # So far so good. But I need 3 matrices of this size. > > > y <- matrix(rep(0, 6600^2), ncol = 6600) > R(3219) malloc: *** mmap(size=348483584) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > R(3219) malloc: *** mmap(size=348483584) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > Error: cannot allocate vector of size 332.3 Mb > > Now a 6600 x 6600 matrix should take up less than 400Mb of RAM. So > the question is, with 20Gb of RAM free how come I can't create more > than one matrix of this size? (In fact, sometimes R won't even create > one of them.) More to the point, is there some simple remedy? > (Rewriting all my code to use the "Matrix" library, for example, is > not a simple remedy.) > > I tried launching R in a terminal with > > R --min-vsize=10M --max-vsize=5G --min-nsize=500k --max-nsize=900M > > and that didn't work either. Finally, let me remark that I had the > same problem with an older version of R. > > -- Steve Ellis > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307
Jonathan Greenberg
2009-Jul-01 20:43 UTC
[R] "Error: cannot allocate vector of size 332.3 Mb"
By the way, you'll probably have to reinstall some or all of your packages (and dependencies) if you are using R64.app, probably downgrading them in the process. --j Steve Ellis wrote:> Dear R-helpers, > > I am running R version 2.9.1 on a Mac Quad with 32Gb of RAM running > Mac OS X version 10.5.6. With over 20Gb of RAM "free" (according to > the Activity Monitor) the following happens. > > > x <- matrix(rep(0, 6600^2), ncol = 6600) > > # So far so good. But I need 3 matrices of this size. > > > y <- matrix(rep(0, 6600^2), ncol = 6600) > R(3219) malloc: *** mmap(size=348483584) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > R(3219) malloc: *** mmap(size=348483584) failed (error code=12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > Error: cannot allocate vector of size 332.3 Mb > > Now a 6600 x 6600 matrix should take up less than 400Mb of RAM. So > the question is, with 20Gb of RAM free how come I can't create more > than one matrix of this size? (In fact, sometimes R won't even create > one of them.) More to the point, is there some simple remedy? > (Rewriting all my code to use the "Matrix" library, for example, is > not a simple remedy.) > > I tried launching R in a terminal with > > R --min-vsize=10M --max-vsize=5G --min-nsize=500k --max-nsize=900M > > and that didn't work either. Finally, let me remark that I had the > same problem with an older version of R. > > -- Steve Ellis > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307
R-helpers, I thank Jonathan Greenberg and David Winsemius for their responses. I will keep R64.app in mind but I found that by deleting some large objects that I didn't need I was able to do my computations using R 2.9.1. (This is consistent with Winsemius's experiment on a 10GB machine.) -- Steve Ellis