[Rd] Memory management issues

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jul 6 00:57:24 CEST 2009

On 05/07/2009 6:05 PM, Yuri D'Elia wrote:
> 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?

No, you're right.

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


Duncan Murdoch

>> 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.
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list