Memory Ballooning
The Guest Additions can change the amount of host memory that a
VM uses, while the machine is running. Because of how this is
implemented, this feature is called memory
ballooning.
-
supports memory ballooning only on 64-bit
hosts. It is not supported on macOS hosts.
-
Memory ballooning does not work well with large pages
enabled. To turn off large pages support for a VM, run
VBoxManage modifyvm vmname --large-pages
off
Normally, to change the amount of memory allocated to a virtual
machine, you have to shut down the virtual machine entirely and
modify its settings. With memory ballooning, memory that was
allocated for a virtual machine can be given to another virtual
machine without having to shut the machine down.
When memory ballooning is requested, the Guest
Additions, which run inside the guest, allocate physical memory
from the guest operating system on the kernel level and lock
this memory down in the guest. This ensures that the guest will
not use that memory any longer. No guest applications can
allocate it, and the guest kernel will not use it either.
can then reuse this memory and give it to another
virtual machine.
The memory made available through the ballooning mechanism is
only available for reuse by . It is
not returned as free memory to the host.
Requesting balloon memory from a running guest will therefore
not increase the amount of free, unallocated memory on the host.
Effectively, memory ballooning is therefore a memory
overcommitment mechanism for multiple virtual machines while
they are running. This can be useful to temporarily start
another machine, or in more complicated environments, for
sophisticated memory management of many virtual machines that
may be running in parallel depending on how memory is used by
the guests.
At this time, memory ballooning is only supported through
VBoxManage. Use the following command to
increase or decrease the size of the memory balloon within a
running virtual machine that has Guest Additions installed:
VBoxManage controlvm "VM name" guestmemoryballoon n
where VM name is the name or UUID of
the virtual machine in question and n
is the amount of memory to allocate from the guest in megabytes.
See .
You can also set a default balloon that will automatically be
requested from the VM every time after it has started up with
the following command:
VBoxManage modifyvm "VM name" --guest-memory-balloon n
By default, no balloon memory is allocated. This is a VM
setting, like other modifyvm settings, and
therefore can only be set while the machine is shut down. See
.