[R] Memory Problems

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Nov 20 09:08:23 CET 1999


On Fri, 19 Nov 1999, Joanna Mills wrote:

> Hi,
> I am sorry to bother you both again but still seem to have the same
> problem and am in dire need of a solution. As you can imagine, taking
> 2+G of our system doesn't make me very popular :-)
> 
> To give you a few more details, my program only passes from R to C once.
> All of the computations are basically done in C, this is where the memory
> seems to be being 'eaten' up. At present I have calloc and cfree
> statements, I tried replacing with R_alloc, no change.
> When I replaced with C_alloc and C_free I got a message saying
> 'all C pointers in use (sorry)'. I tried Init_C_alloc and Reset_C_alloc
> but with no success.
> 
> Do either of you have any other suggestions?

I am neither of those (MP and PD), but I do have a suggestion. C_alloc
(best called via Calloc in S.h) has a limit of 100 `open' calls. So you are
doing a lot of allocating. I just wonder if you are treating an integer
argument passed to your C (say a vector length) as int not int*.  That
aside, it is not normal for a C program to alloc anything like 100 times
(and inefficient), and I think you need to track the calls to the allocator
to see why this is happening (e.g., by adding a debugging print of the
arguments before each one).

Any decent OS will allow you set a limit on the amount of VM you allocate
and so confine the problem. (My computing staff know well how to do this,
from similar experiences.)  It is worth investigating before doing further
experiments.

-- 
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