On Thu, 30 Mar 2006, Jeff Henrikson wrote:
> r-help,
[Moved to R-devel.]
> The R manual lists two types of memory: transient and user-controlled.
> If I have transient blocks reachable from the globals only by traversal
> through user-controlled blocks, will they be correctly preserved?
I don't understand your terminology, especially 'traversal'. It is
not
normal to have either type of block reachable through R objects, and if
you are using something like external pointers, the answer would be no.
> Secondly, what are the ways to mark user controlled blocks as
"roots"
> for the garbage collector, so that transient blocks they reference stay
> uncollected? So far I can only deduce that as long as the answer to my
> first question is yes, I can bind an arbitrary symbol to them in the
> global environment. Is this the best way?
I think you are referring to blocks allocated by R_alloc. The manual says
This memory is taken from the heap, and released at the end of the .C,
.Call or .External call. Users can also manage it, by noting the current
position with a call to vmaxget and clearing memory allocated
subsequently by a call to vmaxset. This is only recommended for experts.
If you want to allocate storage as part of an R object, this is not the
best way to do it (allocVector etc are). It is a side-effect of the
current implementation that memory allocated by R_alloc which is made part
of an object will be protected for the lifetime of that object, but this
is not documented and should not be relied on. (I am thinking if for
example a block is made into a CHARSXP 'by hand', but the documented
route
is mkChar which makes a copy.)
> Jeff Henrikson
>
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Please do, including the question `which list': this clearly belongs on
R-devel.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595