I know I can check the size of an R object using object.size
, but how do I check the total memory usage of R, the memory composition in R - in Rstudio?
I saw this post, but didn't find a Memory usage
button under the Tools
menu.
I'm using Rstudio V 0.99.896 and R V 3.2.5.
Specific context:
I look at Windows Task Manager
when working with R, and I notice the memory usage of the computer increased by ~7G when I read.table
a ~2G data into R.
Use gc()
The help file says
The primary purpose of calling gc is for the report on memory usage.
My understanding is that the
is the most important (human readable) number to check the total amount of memory that R is currently using. You can test this as follows in a fresh session:
gc(verbose=TRUE)
temp <- numeric(1e9)
gc(verbose=TRUE)
The remaining two (human readable) columns describe when automatic garbage collection is triggered and the maximum amount of memory that has been used in the current session.
Check out pryr::mem_used()
.
This should tell you how much RAM all the objects in a particular R session are using.
This should work in RStudio as well as base R.
Here's some more details from Hadley:
http://adv-r.had.co.nz/memory.html#gc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With