[R] "Error: cannot allocate vector of size 332.3 Mb"
Steve Ellis
spe4 at columbia.edu
Wed Jul 1 19:36:46 CEST 2009
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
More information about the R-help
mailing list