Garbage collection


When I use data.table to work with large data sets, does using gc() after some intermediate data are removed improve speed?


Any suggestions? ..................


short answer no, you should never call gc yourself. a explaination can be found on stackoverflow but I'm on mobile right now.


Can you elaborate on it with more details? Thanks.


There is a section on garbage collection in Advanced R.

You can force the garbage collector to run by calling gc() . Despite what you might have read elsewhere, there’s never any need to call gc() yourself. You may want to call gc() to ask R to return memory to your operating system, or for its side-effect of telling you how much memory is currently being used