[Rcpp-devel] Documentation on Rcpp::XPtr class

Dirk Eddelbuettel edd at debian.org
Sun Dec 19 22:20:53 CET 2010


On 19 December 2010 at 14:44, Douglas Bates wrote:
| I have been using external pointers through the Rcpp::Xptr class and
| have encountered memory problems that I think are related to the way I
| construct instances of this class.  I have looked at
| Rcpp/inst/unitTests/runit.XPtr.R and at Rcpp/inst/include/XPtr.h
| (although I haven't read the latter carefully).  There is also a
| section in "Writing R Extensions" on external pointers and weak
| references.  Is there anything that I have missed?

I used them years ago along with early version of bigmemory to hold large
data objects outside of R. 'Back then when' some of the best usage examples I
found where in BDR's use of them in RODBC.

More recently I used them with RcppDE to pass an objective function through
to the optimiser (from DEoptim).  From both instances, I don't recall
anything special.  You essentially just allocates 'something' yourself and
make sure you use it properly. Reference-counted smart pointers help. R and
Rcpp should do nothing with them.

Should we work out an example somewhere as a stanza?  This may make for a
good section in RcppExamples (where I need to complete more use cases of the
new API anyway).

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list