[Rcpp-devel] freeing memory
Dirk Eddelbuettel
edd at debian.org
Sat Mar 26 13:32:03 CET 2016
On 26 March 2016 at 11:35, rosterma at abo.fi wrote:
| rinside_sample1 can only be invoked once, i.e. RInside R remains hanging
| after returning form the function when invoking it as a function. How
| can it be invoked multiple times, some way of freeing the instance of R
| is needed? Simple delete R does not work.
You instantiate R once and it remains running. That is just how R works and
has nothing to do with RInside.
Think of it as a global 'state' you access. The qt/ example pass it around.
If you need / wants function, you have to give them access to the (single) R
instance.
See eg examples/qt/ where main.cpp instantiates an R object and passes it to
the QtDensity class which receives it as a reference it stores in a private
member variable.
And a R instance that is properly setup can be calling as many times as you
want, just like a long-running R session in your shell, RStudio, ...
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list