Preallocate VirtualBox VM RAM for Greater Stability and Avoiding Overcommitment

Memory ballooning and overcommitting RAM has its place and time. Like squeezing juice out of your oversold servers to, in turn, squeeze pennies from your hapless VPS customers. In a mission critical environment you may prefer to know that the RAM you have pledged to your virtual machines is going to be there when they need it. This is especially true under Oracle VM VirtualBox which allocates RAM to VMs "lazily" - that is to say VMs are started with a minimum allotment and new pages of host RAM are assigned as they are requested. When the page manager request RAM from the host which is not presently available your VM will be automatically paused - and never resumed until you notice it and manually intervene.

I have also read conjecture that due to ZFS's intense and particular method of caching, memory allocations to VMs can be highly non-contiguous which may have performance or stability implications. Don't quote me on that - I don't want to be responsible for spreading myths but when you run into unexplained crashes sometimes the kitchen sink is all one has.

To ensure RAM is preallocated for a given virtual machine on startup (or it won't start at all - and that is a far better condition than pausing at some indeterminate time down the road!) run:
$ VBoxManage setextradata vmname VBoxInternal/RamPreAlloc 1


There are no comments for this item.