From wavexx at users.sf.net  Mon Jul  6 00:05:18 2009
From: wavexx at users.sf.net (Yuri D'Elia)
Date: Mon, 06 Jul 2009 00:05:18 +0200
Subject: [Rd] Memory management issues
References: <20090705165445.68dae639@abz8111lx.eurac.edu>
	<4A5102FF.8040303@stats.uwo.ca>
Message-ID: <wavexx-25F071.00051806072009@ger.gmane.org>

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.



[Rd] Memory management issues
Yuri D'Elia