[Rcpp-devel] reference counting, garbage collection, etc ....
Romain François
francoisromain at free.fr
Sat Jan 2 13:37:18 CET 2010
Hi,
Right, so looking at R_PreserveObject and R_ReleaseObject (still waiting
for some insight from R-devel) it seems that we can preserve and release
the same SEXP more than once. preserve adds the sexp to the list of
preserved SEXP (even if it is there already), and release release the
first one it finds.
This leads me to thinking that we should make the garbage collection
stuff automatic and hidden, i.e when setting the SEXP of an RObject, we
automatically preserve it, and we release it automatically when the
object goes out of scope.
Currently we have to manage this business manually, which will leads to
problems.
So i propose that RObject::m_sexp becomes private (as opposed to
protected) and we had a protected setSEXP that :
- release the current SEXP if there is one
- preserve the new SEXP
and make preserve and release protected (maybe even private members of
RObject), and remove the preserved bool.
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/IW9B : C++ exceptions at the R level
|- http://tr.im/IlMh : CPP package: exposing C++ objects
`- http://tr.im/HlX9 : new package : bibtex
More information about the Rcpp-devel
mailing list