From ruipbarradas at sapo.pt  Fri Dec  7 19:45:57 2012
From: ruipbarradas at sapo.pt (Rui Barradas)
Date: Fri, 07 Dec 2012 18:45:57 +0000
Subject: [Rd] memory management in C code
In-Reply-To: <CADdZhHbSN3u49xDYGK7a5oawX0LaM7=h6BL9AC0Mw35f25xhRQ@mail.gmail.com>
References: <CADdZhHbSN3u49xDYGK7a5oawX0LaM7=h6BL9AC0Mw35f25xhRQ@mail.gmail.com>
Message-ID: <50C23965.5080205@sapo.pt>

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



[Rd] memory management in C code
Rui Barradas