[Rd] Memory management issues

Yuri D'Elia wavexx at users.sf.net
Mon Jul 6 00:05:18 CEST 2009

In article <4A5102FF.8040303 at stats.uwo.ca>,
 Duncan Murdoch <murdoch at stats.uwo.ca> wrote:

> > What I'd would like to do is:
> > 
> > - "patch" the SEXP returned to R so that DATAPTR() points directly to
> >   the required address. 
> The normal way to do what you want is to use an "external pointer".  R 
> assumes that memory management for those is handled completely 
> externally.  External pointers can have finalizers, so when you no 
> longer have a need for the object, you can ask the external library to 
> release it.

I don't think external pointers can be read from R sources like normal 
vectors, or am I wrong?

Using external pointers would imply either proxy calls for every action 
you need to perform or deep copies (like I'm doing now).

> I wouldn't try to trick the memory manager into thinking that it 
> allocated these things; that will likely just lead to problems.

I'm not afraid of patching R sources somehow, if that's the only 
solution, but it's one that I would like to avoid.

More information about the R-devel mailing list