[R] outer(-x, x, pmin) cannot allocate

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Dec 22 23:24:18 CET 2004

"Brahm, David" <David.Brahm at geodecapital.com> writes:

> R> x <- 0. + 1:8000
> R> y <- outer(-x, x, pmin)
> Error: cannot allocate vector of size 1000000 Kb
> Why does R need to allocate a gigabyte to create an 8000 x 8000 matrix?
> It doesn't have any trouble with outer(-x, x, "+").  Thanks.

Hmm, it does run the process size to over 5GB on systems that do not
crash. An 8000x8000 matrix of doubles takes about 0.5 GB, and the way
outer() works, it expands both arguments to vectors of the same length
as the result.

So needing a GB is not too surprising, but something does seem to be a
bit memory hungry. Looking inside pmin, it is pretty clear that it
wasn't built for memory efficiency...

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907

More information about the R-help mailing list