memory-management
Andreas Weingessel
Andreas.Weingessel@ci.tuwien.ac.at
Thu, 6 Aug 1998 13:06:11 +0200 (CEST)
R has some strange behavior in its memory management. (R-0.62.2 and
R-0.63.0 of July 22)
If I start R on a PC with 256MB with the option -v 200, and want to
see the free memory I get
R> gc()
Garbage collection ...
111801 cons cells free (55%)
204554k bytes of heap free (-63%)
So, I have suddenly a negative percentage of memory free. This value
becomes not positive, unless a certain amount of memory is used.
R> x <- matrix(0,1000,1000)
R> gc()
Garbage collection ...
111797 cons cells free (55%)
196741k bytes of heap free (-67%)
R> x <- matrix(0,4000,1000)
R> gc()
Garbage collection ...
111797 cons cells free (55%)
173304k bytes of heap free (-79%)
R> x <- matrix(0,5000,1000)
R> gc()
Garbage collection ...
111797 cons cells free (55%)
165491k bytes of heap free (80%)
The second point I came across is the following. R is now started with
-v 100 -n 1000000. After
R> x <- matrix(0,5000,900)
I have still enough memory free.
R> gc()
Garbage collection ...
911797 cons cells free (91%)
66997k bytes of heap free (65%)
So, if x uses 35% of heap memory, there should still be enough memory
for a second matrix of this size, but the command
R> y <- matrix(0,5000,900)
runs out of heap memory.
Similarly, I can create a 5000x1300-matrix on a newly started R with
-v 100 and have still 50% heap memory free, but I can not create a
5000x1400-matrix, if R is started with -v 100. So, I suppose that R
needs a complete copy of this matrix while creating it and therefore I
can only create matrices which use less than half of the free
memory. Is there any way to avoid this memory usage?
************************************************************************
* Andreas Weingessel *
************************************************************************
* Institut f=FCr Statistik * Tel: (+43 1) 58801 4541 =
*
* Technische Universit=E4t Wien * Fax: (+43 1) 504 14 98 =
*
* Wiedner Hauptstr. 8-10/1071 * Andreas.Weingessel@ci.tuwien.ac.at *
* A-1040 Wien, Austria * http://www.ci.tuwien.ac.at/~weingessel *
************************************************************************
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._