From jens.oehlschlaegel-akiyoshi@mdfactory.de  Fri Feb 11 12:15:03 2000
From: jens.oehlschlaegel-akiyoshi@mdfactory.de (=?iso-8859-1?Q?Jens_Oehlschl=E4gel-Akiyoshi?=)
Date: Fri, 11 Feb 2000 13:15:03 +0100
Subject: [Rd] astonishing memory phenomenon
Message-ID: <000501bf7489$a0811960$a9021aac@joelschlaegel>



I have a question concerning memory.

I understood that R takes a fixed amount of memory at startup (which I can
influence with --vsize --nsize) and that gc() shows the memory still free of
the total memory reserved for R.

However, if I create a long vector of character data, gc() only seem to
reflect the space needed for a vector of pointers to char, the space used
for the character data itself is ... hidden!?

Here the data: I have 6 MB heap, and can do

> x <- rep(1, 350000); gc(); rm(x); gc()
         free  total (Mb)
Ncells  61034 250000  4.8
Vcells 350955 786432  6.0
         free  total (Mb)
Ncells  61036 250000  4.8
Vcells 700956 786432  6.0

which is using about 2.67 MB RAM for double numbers.

Trying for 3.05 MB fails (well, rep() obviously needs twice the memory, x <-
double(700000) works)

> x <- rep(1, 400000); gc(); rm(x); gc()
Error: heap memory (6144 Kb) exhausted [needed 3125 Kb more]
       See "help(Memory)" on how to increase the heap size.

Now character data, gc() tells us, that we need half that much RAM as
compared to double numbers.
for empty character WHATEVER SIZE THE CHARACTER DATA HAVE

> x <- rep(paste(rep("0", 0), collapse=""), 700000); gc(); rm(x); gc()
         free  total (Mb)
Ncells  61036 250000  4.8
Vcells 350955 786432  6.0
         free  total (Mb)
Ncells  61039 250000  4.8
Vcells 700958 786432  6.0

> x <- rep(paste(rep("0", 4096), collapse=""), 700000); gc(); rm(x); gc()
         free  total (Mb)
Ncells  61033 250000  4.8
Vcells 350441 786432  6.0
         free  total (Mb)
Ncells  61036 250000  4.8
Vcells 700956 786432  6.0


> x <- rep(paste(rep("0", 8192), collapse=""), 700000); gc(); rm(x); gc()
Error: heap memory (6144 Kb) exhausted [needed 2734 Kb more]
       See "help(Memory)" on how to increase the heap size.


Furthermore the last x successfully  created should contain data of size
700000*4096 Bytes corresponding to  700000*4096/1024/1024 = 2734 MB, which
is impossible given the startup memory, impossible given RAM, impossible
given that no swaping occurs, furthermore the OS (WinNT4) never shows any
additional memory eaten up except that taken at startup.

What's going on?
Regards


Jens Oehlschlgel-Akiyoshi




> version
         _
platform Windows
arch     x86
os       Win32
system   x86, Win32
status
major    0
minor    90.1
year     1999
month    December
day      15
language R





Dr. Jens Oehlschlgel-Akiyoshi
MD FACTORY GmbH
Bayerstrasse 21

80335 Mnchen

Tel.: 089 545 28-27
Fax.: 089 545 28-10
http://www.mdfactory.de

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] astonishing memory phenomenon
=?iso-8859-1?Q?Jens_Oehlschl=E4gel-Akiyoshi?=