[R] RAM usage

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Mon Oct 21 15:02:49 CEST 2002


On Mon, 21 Oct 2002, Vaidotas Zemlys wrote:

> Hi,
>
>
>  >> I'm having problems while working with large data sets with R 1.5.1 in
>  >> windows 2000. Given a integer matrix size of 30 columns and  15000 rows
>  >> my function should return a boolean matrix size of about 5000 rows and
>  >> 15000 columns.
>
>  >That's  75million items of 4bytes each, hence almost 300Mb for that one
>  >object.
>
> Does that mean that R reserves 4 bytes for logical object with length 1? On
> the whole how much memory R allocates for different data types? I searched

R uses C integers, which are almost always 4 bytes.  Fortran does
for logicals usually, for example, and that's probably why S did.  It's
quite hard to work with smaller types in a portable way.  (char need not
be 1 byte, for example.)

A logical vector of length 1 needs a lot more than 4 bytes, but one of
length 1e5 will be close to 4e5 bytes (unless it has names).  There's
overhead and lignment issues to consider.

> a bit, but I didn't find anything useful on this subject. I would like to
> know if it is possible how much memory R needs for storing for example real
> matrix size of 50 rows and 100 columns together with column and row names.
> Or where to find information on such subject.

In the source files.  reals are stored in the system's C double type,
which is usually 4 bytes.

> I thought that R needs only 1 byte for storing logical byte, and because of
> that I underestimated the size of memory R would need to use.
>
>
>  > You have not told us your problem, so has not demonstrated that
>  > `a lot of memory must be used'.   Hard to help when we don't know what
>   > you are attempting, but few problems cannot be done in pieces
>
> I did not tell my problem, because I thought that it was more or less
> irrelevant to the memory usage problems I was experiencing. My intention
> was to ask about how R manages memory and is there something special about
> that management everyone should know, but I don't know. I'm sorry if my
> letter was a bit unclear, English is not my native language.

But you did claim `must be used'.  That really is rarely the case, and the
skill in programming R (or S) is use memory within the resources
available.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list