peakRAM icon indicating copy to clipboard operation
peakRAM copied to clipboard

RAM used by C code?

Open tdhock opened this issue 8 years ago • 1 comments

Hey @tpq interesting package! It looks like you use gc() to track memory usage, right? I like the portability of your approach (I see from the CRAN check page https://cran.r-project.org/web/checks/check_results_peakRAM.html that it works on all systems).

But because you use gc() that means that any code that calls C and allocates memory outside of the R garbage collector will not be counted, right?

@analyticalmonk did something similar in https://github.com/analyticalmonk/Rperform but we ended up using the ps command line program to measure memory https://github.com/analyticalmonk/Rperform/blob/master/exec/rss.sh so we could count all memory that the R process is using (even outside of the garbage collector). one issue with this approach is that it only works on systems with the ps program.

tdhock avatar Jun 21 '17 19:06 tdhock

Thanks for your interest, @tdhock. I must admit that I know little about how C allocates memory, but I have a feeling you're right. I had originally written this package for benchmarking my own Rcpp code, for which it seems to work quite well. As I understand it, Rcpp exposes all C++ objects to the R garbage collector via SEXP intermediaries.

tpq avatar Jun 22 '17 10:06 tpq