[R] outer(-x, x, pmin) cannot allocate
tlumley at u.washington.edu
Thu Dec 23 00:06:16 CET 2004
On Wed, 22 Dec 2004, Peter Dalgaard wrote:
> "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...
It's not just needing a Gb that was surprising, but needing a single
object of size 1Gb. However, that is because pmin() cbind()s its
arguments together, giving a 8000x8000x2 array: 8000x8000x2x8=1Gb.
More information about the R-help