Skip to content

Instantly share code, notes, and snippets.

@daviddalpiaz
Created September 21, 2019 13:57
Show Gist options
  • Save daviddalpiaz/82bc6428e65ed305db330be98cf68b2a to your computer and use it in GitHub Desktop.
Save daviddalpiaz/82bc6428e65ed305db330be98cf68b2a to your computer and use it in GitHub Desktop.
function for checking memory using on RStudio Cloud
check_mem = function() {
mem_lim = as.numeric(system("cat /sys/fs/cgroup/memory/memory.limit_in_bytes", intern = TRUE)) * 0.000001
mem_use = as.numeric(system("cat /sys/fs/cgroup/memory/memory.usage_in_bytes", intern = TRUE)) * 0.000001
prc_free = mem_use / mem_lim * 100, 1
prc_used = 100 - prc_free
memory_info = c("Used (MB)" = mem_use,
"Free (MB)" = mem_lim - mem_use,
"Used (%)" = prc_used,
"Free (%)" = prc_free)
round(memory_info, 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment