From mjhubisz at gmail.com  Mon Apr 19 16:39:25 2010
From: mjhubisz at gmail.com (Melissa Jane Hubisz)
Date: Mon, 19 Apr 2010 10:39:25 -0400
Subject: [Rd] transient memory allocation and external pointers
Message-ID: <u2z3aa2e7491004190739o1d6bcffbi997ac207d51865e0@mail.gmail.com>

Hello,
The Writing R extensions manual section 6.1.1 describes the transient
memory allocation function R_alloc, and states that memory allocated
by R_alloc is automatically freed after the .C or .Call function is
completed.  However, based on my understanding of R's memory handling,
as well as some test functions I have written, I suspect that this is
not quite accurate.  If the .Call function returns an external pointer
to something created with R_alloc, then this object seems to stick
around after the .Call function is completed, and is subject to
garbage collection once the external pointer object is removed.

Does anyone know, can I count on this behavior on any platform?  It
would certainly be useful for me.  ie, Can I create an external
pointer to something created with R_alloc, and trust that it will not
be free'd until the external pointer object is removed?  And if so,
should the manual be edited to describe this behavior?
Thanks,
Melissa Hubisz



[Rd] transient memory allocation and external pointers
Melissa Jane Hubisz