From murdoch at stats.uwo.ca  Mon Jul  6 00:57:24 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sun, 05 Jul 2009 18:57:24 -0400
Subject: [Rd] Memory management issues
In-Reply-To: <wavexx-25F071.00051806072009@ger.gmane.org>
References: <20090705165445.68dae639@abz8111lx.eurac.edu>	<4A5102FF.8040303@stats.uwo.ca>
	<wavexx-25F071.00051806072009@ger.gmane.org>
Message-ID: <4A512FD4.7090107@stats.uwo.ca>

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).

Yes.

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



[Rd] Memory management issues
Duncan Murdoch