Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM used by C code? #2

Open
tdhock opened this issue Jun 21, 2017 · 1 comment
Open

RAM used by C code? #2

tdhock opened this issue Jun 21, 2017 · 1 comment

Comments

@tdhock
Copy link

tdhock commented Jun 21, 2017

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.

@tpq
Copy link
Owner

tpq commented Jun 22, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants