How to clean up R memory (without the need to restart my PC)?

后端 未结 8 922
小蘑菇
小蘑菇 2020-12-07 14:37

I am running my code in R (under Windows) which involves a lot of in-memory data. I tried to use rm(list=ls()) to clean up memory, but seems the memory is still

8条回答
  •  既然无缘
    2020-12-07 15:06

    Just adding this for reference in case anybody needs to restart and immediatly run a command.

    I'm using this approach just to clear RAM from the system. Make sure you have deleted all objects no longer required. Maybe gc() can also help before hand. But nothing will clear RAM better as restarting the R session.

    library(rstudioapi)
    restartSession(command = "print('x')")
    

提交回复
热议问题