Tips for using RStudio Server on BioHPC

See this page for how to start RStudio Server on BioHPC.

When you use RStudio Server to process large data matrix, RStudio loads the data matrix into the computer's memory space. If RStudio detects 2 hours of inactivity, it would free the memory space by saving your current r-session data into the hard drive. Next time you login to the RStudio web site, it would automatically reload the cached r-session data file into the memory space. The "reloading" step could take a very long time if you are working with large data objects.

  1. If your server has sufficient memory, you can prevent RStudio from caching your r-session data onto the hard drive. This way, even if you close the RStudio web page, RStudio will keep the r-session data in memory. Next time, you can login to RStudio without delay. However, if the server is shared by several people, this practice may consume excessive memory.

To prevent hard drive caching, you can start RStudio with "noswap" as the last parameter. For example

#start RStudio with default R version 4.2.1

#start RStudio with a different R-version

 

  1. Move the RStudio cache directory to /workdir. By default, RStudio caches your r-session data under your home directory ("/home/$USER/.local/share/rstudio"). In BioHPC, your home directory is on a slow network drive. Run this command to clear the current cached r-session data, and move the cache to /workdir. This will speed up the "reloading" step.

  1. "Clear Workspace" once in a while. On the RStudio web page, clicking "Session"->"Clear Workspace", then "Tools"->"Memory"->"Free unused memory" will delete all R objects and free the memory. Make sure to save important R objects into files before you clear workspace.

To save an R object:

To reload an R object from file:

To list sizes of all R objects in your workspace:

To delete an R object from your workspace

 

  1. What to do if RStudio freezes?

    • ssh to the Linux shell, and kill all rsessions:

    • Delete your R session file