Skip to content

Instantly share code, notes, and snippets.

@arnauldvm
Last active March 13, 2019 15:37
Show Gist options
  • Save arnauldvm/ea1133b69e692ab92bab8335dc4b7961 to your computer and use it in GitHub Desktop.
Save arnauldvm/ea1133b69e692ab92bab8335dc4b7961 to your computer and use it in GitHub Desktop.
R session cleanup
while (sink.number()>0) sink(file=NULL) # Close all remaining files opened by a previous run
cat("All file descriptors closed.\n")
rm(list=ls()); gc() # Clean up as much memory as possible
# Replace by the following line if you want to keep getargs array to retrieve arguments:
# rm(list=grep("getargs", ls(), fixed=T, value=T, invert=T)); gc()
cat("Whole memory cleaned.\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment