Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-08 Thread Pierre . Gloaguen
Hello Jonhatan and Dirk, It seems that the whole issue that I encountered was contained in this "off by 1" in the loop. I feel a bit stupid for that :). I can now compute the operation 10^8 times (embedded in another function) without any problem so far, and without using R function gc(). Jus

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-08 Thread Dirk Eddelbuettel
On 8 October 2014 at 00:07, Jonathan Olmsted wrote: | Have you used a tool like Valgrind? There is a bit of a learning curve, but it | is exceedingly useful. Excellent point. And the "Writing R Extensions" manual has a few tips. Reading the output of valgrind takes a little getting used to thou

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-08 Thread Jonathan Olmsted
> > So, you think I should go to postfix increments instead of prefix? > I'm a beginner in C++, so I'm not comfortable on which of them to chose. > ​I was just giving some tips in case you needed to look at the output from Valgrind. When using the prefix, Valgrinds messages didn't lead me right to

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Pierre . Gloaguen
Hello Jonathan, Thanks a lot for your help. I didn't know valgrind, but i'll definitely go into it. Thanks very much for your help. So, you think I should go to postfix increments instead of prefix? I'm a beginner in C++, so I'm not comfortable on which of them to chose. You seem to be righ

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Jonathan Olmsted
Pierre, Have you used a tool like Valgrind? There is a bit of a learning curve, but it is exceedingly useful. A few comments: 1) For cases likes this gctortute(TRUE) in your R script helps those “for enough iterations in a loop…” bugs to present quickly. With gctorture(TRUE) I’m producing the cr

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Dirk Eddelbuettel
Hi Pierre, On 8 October 2014 at 01:59, pierre.gloag...@ifremer.fr wrote: | I will do what I can to reduce the code and have to same error occuring. | Of course i don't expect you to read all of it :) I was just wondering | if that kind of memory problem occured before, and if has some | "typi

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Pierre . Gloaguen
Hello Dirk, I will do what I can to reduce the code and have to same error occuring. Of course i don't expect you to read all of it :) I was just wondering if that kind of memory problem occured before, and if has some "typical/generic" solutions. I will try to have a shortest code to exhibi

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Dirk Eddelbuettel
On 8 October 2014 at 01:20, pierre.gloag...@ifremer.fr wrote: | Hello Dirk, and everyone, | | I sadly was too optimistic thinking that a gc() would solve the problem. | The main_function_C I wrote was putted in a more general function | named simu_cond_ea_C [...] | Any clue about the origin of

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-07 Thread Pierre . Gloaguen
Hello Dirk, and everyone, I sadly was too optimistic thinking that a gc() would solve the problem. The main_function_C I wrote was putted in a more general function named simu_cond_ea_C List simu_cond_ea_C(arma::vec X0,arma::vec XF, double t0, double tF, NumericVector time

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-06 Thread Pierre . Gloaguen
Dirk Eddelbuettel a écrit : On 6 October 2014 at 23:36, pierre.gloag...@ifremer.fr wrote: | Hello, | | I have found out that the problem was in the R loop, the garbage | collection of R wasn't perform efficiently. Indeed, when I force the | garbage collection to be done, using R function gc(),

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-06 Thread Dirk Eddelbuettel
On 6 October 2014 at 23:36, pierre.gloag...@ifremer.fr wrote: | Hello, | | I have found out that the problem was in the R loop, the garbage | collection of R wasn't perform efficiently. Indeed, when I force the | garbage collection to be done, using R function gc(), the Rsession | won't cra

Re: [Rcpp-devel] R session crashes when largely using a Rcpp sourced function

2014-10-06 Thread Pierre . Gloaguen
Hello, I have found out that the problem was in the R loop, the garbage collection of R wasn't perform efficiently. Indeed, when I force the garbage collection to be done, using R function gc(), the Rsession won't crash, although the execution of the loop will be slower. This leads me to an