TL;DR: I did a lot of digging and could not find anything that even hinted at a "minimum memory size" setting.
If I understand your question correctly, you would like to have R request a very large (20 Gb) amount of memory up front for a session and then manage this memory on its own in order to ensure that resources are available when needed. From what I have been able to gather, this is not possible and it is approximately the opposite of the strategy employed by R’s designers.
As you have stated, R allocates and manages memory by:
- Setting a max limit for the session
- Allocating as objects are created
- Within certain limits, reclaiming memory as soon as the object is done
For small allocations, I think step 3 is done using the C function alloca()
which uses the stack and for larger ones it uses malloc()
which allocates on the heap. What this effectively means is that R can request a small pool of memory (128 bytes, according to Advanced R) to manage itself for small objects that come and go pretty quickly, but for larger objects it lets the operating system handle it.
All of the focus I have seen from comments in the source and R internals suggests that the dev team was focused on writing software that would only hold the amount of memory needed for current computation and then promptly release it:
We want the heap sizes to get set at levels adequate for the current
computations. The present mechanism uses only the size of the current
live heap to provide information about the current needs; since the
current live heap size can be very volatile, the adjustment mechanism
only makes gradual adjustments. A more sophisticated strategy would
use more of the live heap history (lines 314 – 320 in source)
That being said, there could be a package or extension that has re-written some of this core functionality that I am not aware of – although this seems like such a dramatic departure from the way R was written it would probably be a fork of the project rather than a package. If you are not interested in doing that yourself, I would recommend a more mundane solution, like running your program overnight to avoid competition for resources. Or incrementally processing your data, or seeing if something like a database or the bigmemory
package could help you. Good luck!