Created
September 21, 2019 13:57
-
-
Save daviddalpiaz/82bc6428e65ed305db330be98cf68b2a to your computer and use it in GitHub Desktop.
function for checking memory using on RStudio Cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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