Where does R store temporary files

memory, r

Solution

R writes to a temporary per-session directory which it also cleans up at exit.

It follows convention and respects TMP and related environment variables.

Problem

I am running some basic data manipulation on a Macbook Air (4GB Memory, 120GB HD with 8GB available). My input file is about 40 MB, and I don't write anything to the disk until end of the process. However, in the middle of my process, my Mac says there's no memory to run. I checked hard drive and found there's about 500MB left. So here are my questions: - How is it possible that R filled up my disk so quickly? My understanding is that R store everything in memory (unless I explicitly write something out to disk). - If R does write temporary files on the disk, how can I find these files to delete them? Thanks a lot. Update 1: error message I got: ``` Force Quit Applications: Your Mac OS X startup disk has no more space available for application memory ``` Update 2: I checked tempdir() and it shows "var/folders/k_xxxxxxx/T//Rtmpdp9GCo". But I can't locate this director from my Finder Update 3: After unlink(tempdir(),recursive=TRUE) in R and restarting my computer, I got my disk space back. I still would like to know if R write on my hard drive to avoid similar situations in the future. Update 4: My main object is about 1GB. I use Activity Monitor to track process, and while Memory usage is about 2GB, Disk activity is extremely high: Data read: 14GB, data write, 44GB. I have no idea what R is writing.

Original source

Related problems