[Rd] memory management in C code

Rui Barradas ruipbarradas at sapo.pt
Fri Dec 7 19:45:57 CET 2012


Hello,

This is explained in Writing R Extensions, Section 6.1 file R-exts.pdf 
in your distribution of R, folder doc.
There are two types of functions to allocate memory in C functions 
called from R code.

1. R_alloc() - the memory is automatically reclaimed at the end of the 
function call.
2. Calloc/Realloc - you must call Free() [ uppercase, not free() ] at 
the end of the function call.

Hope this helps,

Rui Barradas
Em 07-12-2012 12:40, Vineeth Mohan escreveu:
> Hi ,
>
> I am a newbie to R and i am trying to create a R package which is pretty
> main memory intensive.
> I would like to know what happens to the variables allocated in the C code
> while writing R extensions based on C.
> Are they preserved until someone de-allocate them or are they taken out by
> R's garbage collection ?
>
> Thanks
>             Vineeth
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list