This shouldn't be necessary, since R (usually) handles this correctly and automatically. However, sometimes when working with large geospatial data (e.g., using raster and sp packages) it can help to free recently unallocated memory manually.

.gc()

See also

Author

Alex Chubaty