Skip to content

R Memory Issues

2 messages · carl mela, Brian Ripley

#
I am running R code (version 1.3.1) on a PC with 650 Mb of RAM, and
after a number of iterations of the code (each iteraction corresponds to
a set of draws in an MCMC algorithm), the program runs out of memory
(however, the number of iterations before the code runs out of memory is
quite variable).

After each iteration in the code, I run the following lines to ascertain
the memory demanded by R:

z_sapply(ls(), function(x) object.size(get(x)))
totmem_sum(as.matrix(rev(z)))
print ("totmem")
print (totmem)

Interestingly, the total size of all of the objects does not increase
with each iteration, as the objects are overwritten from iteration to
iteration.  So, for some reason R is consuming more memory each
iteration, even though the objects do not increase in size.  I have even
tried to issue a gc() command after each iteration, but this does not
help.

I would appreciate any advice from those on this list-serv regarding how
to solve this problem.  Thanks.

--
Carl F. Mela
Associate Professor of Marketing
Fuqua School of Business
Duke University
134 Tower View Drive, Box 90120
Durham, North Carolina 27708-9012
Phone: 919-660-7767
Fax: 919-681-6245
Email: mela at duke.edu
Web: http://faculty.fuqua.duke.edu/~mela/bio

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mela.vcf
Type: text/x-vcard
Size: 381 bytes
Desc: Card for carl mela
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20011010/086624e2/mela.vcf
#
On Wed, 10 Oct 2001, carl mela wrote:

            
There are much better ways to see the real memory usage. gc() for a start,
and on Windows see ?memory.size.

You may well be suffering from the way Windows manages memory: it is
entirely possible that it is not running out of memory, just fragmenting
it so it cannot allocate the chunks you want.

I suggest you re-compile R reserving a much larger initial chunk of memory
(RESERVED_SIZE in src/gnuwin32/malloc.c: set it above your RAM size) and
see if this helps.
Next time please report exactly what messages you got!