[R] Memory Problems
Martyn Plummer
plummer at iarc.fr
Fri Nov 19 18:02:43 CET 1999
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