How much ram do you have? What kind of data do you have? How big are the files on disk? (And...What do you want to do?)
- A first approach might be the useage of
ls(), pryr::mem_used() and pryr::object_size() to determine, if there are any unnecessary objects in ram. If so, just use rm(). Be careful whenever you assign your data to another name and change the old or the new object afterwards (memory size might double).
- If you have independent objects and just want to process each of them, you might just be able to use some looping pattern involving for example
readRDS() and saveRDS() to have less objects in memory at the same time.
- Otherwise, the other threads, mentioned above, might include more possibilities.
If you want to understand R's memory management in more detail, the memory chapter in Advanced R is a good start.