Re: [Rcpp-devel] bool from list: unexpected result and differences between compilers/OSs

2015-06-23 Thread Ramon Diaz-Uriarte
Hi Dirk, On Mon, 22-06-2015, at 13:21, Dirk Eddelbuettel wrote: > On 22 June 2015 at 10:25, Ramon Diaz-Uriarte wrote: > | > | Dear All, > | > | Accessing an element of a list that should be TRUE/FALSE does not recognize > | the boolean properly in Windows/gcc-4.6.3 unless I use "as". It does t

[Rcpp-devel] rsession memory consumption blows up

2015-06-23 Thread Fabio Tordini
Hello, I encountered this problem while working on my Rcpp package. I don't know if it can be related to Rcpp, but I post it here looking for some advices. I'll try to make myself as clear as possible: from an R function in my Rcpp package I call a C++ function where huge datasets (~ 2GB) ar

Re: [Rcpp-devel] rsession memory consumption blows up

2015-06-23 Thread Dirk Eddelbuettel
On 23 June 2015 at 18:45, Fabio Tordini wrote: | it seems like the C++ function, once it terminates its execution, does | not free the memory used. instead, rsession keeps holding these objects | even though C++ has terminated. is it possible? Of course. We all have bad days every now and then

Re: [Rcpp-devel] rsession memory consumption blows up

2015-06-23 Thread Hao Ye
I’m not that familiar with R’s garbage collection, but maybe you can call something manually to free up memory? > rewrite your program to work more incrementally and releasing memory as > needed. Or the simple alternative solution is to free everything but the objects to be returned in the fun

[Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Charles Determan
I am exploring the use of some XPtr objects. For example, I can create a pointer to an armadillo matrix. I can then create a copy of that matrix from the pointer within the same function. However, when I try to pass a pointer to a function and create a new copy from said pointer it fails (return

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Dirk Eddelbuettel
Charles, Maybe a close look at this will help: http://gallery.rcpp.org/articles/passing-cpp-function-pointers/ Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org h

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Charles Determan
Hi Dirk, I was actually looking at that very page. However, I am still not sure what I am missing here. I am not passing any pointers to functions, just the data object. Like I said, I feel like I must be missing something obvious but cannot figure it out. I fail to see what is distinguishing

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread John Buonagurio
Hi Charles, > SEXP testXptr(SEXP A) > { > arma::Mat armaMat = Rcpp::as >(A); > Rcpp::XPtr pMat(armaMat.memptr()); > return(pMat); > } armaMat is on the stack, so the Armadillo memptr is no longer valid when you return from the testXptr function. One simple solution in your case woul