[R] another memory size question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Apr 14 10:11:44 CEST 2006
On Fri, 14 Apr 2006, Alexander Nervedi wrote:
> I am having trouble figuring this out. Please help if you know what I am
> goffing up on.
>> dat<-expand.grid(village.code = c(1,2,3), household.id = 1:99, member.id =
>> 1:41, year.code = 75:85, DOI = 1:366)
> Error: cannot allocate vector of size 191502 Kb
>  3145728000
> Shouldn't I have ample memory to greate this gigantic grid?
No. It has 3*99*41*11*366 = 50m rows, and 5 columns needing 24 bytes per
row (1 double plus 4 integer cols, I believe), plus rowmanes. Now
normally rownames are a character vector, and a character vector of that
size needs over 2Gb of storage (on a 32-bit machine), but expand.grid
`cheats' (actually, it is a bug) by using integer rownames and hence you
would have 28 bytes per row, 1.4GB in total. You do have enough memory to
store that, but not enough address space.
BTW, you seem to be on Windows (but failed to mention it): please consult
the rw-FAQ as the memory limit is not necessarily the limiting factor
here (the address space is probably 2GB).
> mucho gracias el signors and signioritas,
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help