Limit R memory on POSIX systems (Linux, OS X, …).
devtools::install_github("krlmlr/ulimit")
Execute the following to limit the memory available to R to 2000 MiB:
ulimit::memory_limit(2000)
See also the package documentation and the small vignette.
memory_limit
ulimit-package
(ulimit)