2

I would like to check what is the top usage of memory during running a code in R. Does anyone know such a function?

The only thing I found, so far, is the function mem_change from pryr package, which checks memory change before and after running a code.

I work on Linux.

4
  • 3
    To analyse after code has run use Rprof or Rprofmem. If you are looking for real time memory use, I don't think there is anything in R. Commented Jun 12, 2015 at 10:06
  • 2
    memory.size(max=TRUE) returns pick usage during session. Start with fresh session, run your code and check this value. Commented Jun 12, 2015 at 15:43
  • Marek: memory.size and memory.limit are used to manage the total memory allocation on Windows. I should have mentioned that I work on Linux :) Commented Jun 13, 2015 at 10:14
  • There is also ulimit package on github, link to short vignette: krlmlr.github.io/ulimit/vignettes/ulimit.html Commented Jun 16, 2015 at 9:36

1 Answer 1

4

gc() will tell you the maximum memory usage. So if you start a new R session, run your code and then use gc() you should find what you need. Alternatives include the profiling functions Rprof and Rprofmem as referenced in @James comment above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.