[R] Memory Problems

Joanna Mills millsje at mscs.dal.ca
Fri Nov 19 21:25:58 CET 1999


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?

Thank you both very much for your time,
Joanna

Joanna Elizabeth MILLS, M.Sc.               Ph:  (902) 494-3747
Dalhousie University                        Fax: (902) 494-5130
Department of Mathematics and Statistics    Res: (902) 443-0230
Halifax, N.S. Canada B3H 3J5                millsje at mscs.dal.ca

On Fri, 19 Nov 1999, Martyn Plummer wrote:

> On 19-Nov-99 Peter Dalgaard BSA wrote:
> > Joanna Mills <millsje at mscs.dal.ca> writes:
> > 
> >> I have an R program which basically reads in data. It then
> >> calls a  C program which performs numerical integration until converging
> >>  to a solution.  The result is then passed back from C to R.
> >> Unfortunately, when running this program, the virtual
> >> memory associated with it explodes -> 2GIG!. Does anyone know what might
> >> be causing this or can suggest possiblie ways to debug?
> >
> > Sounds as if the C routine is allocating memory and not freeing it?
> > 
> > You may want to check up on R_alloc (now where did we document that? I
> > can find various hints in help(Memory), help(dyn.load), and help(.C),
> > and in the R-external that will be in the upcoming release, but
> > nothing really coherent.)
> 
> There is some documentation of R_alloc in the source file
> src/main/memory.c which was enough to get me started.
> 
> The nice thing about R_alloc is that memory is freed automatically by the
> .C interface if you forget to do it. Even better, you can use the error()
> function to exit gracefully from your C code when there is a problem,
> and the R_alloc'ed memory will also be freed. I don't think this is documented.
> 
> Martyn
> 

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