Memory overcommitment
To ensure optimal use of host memory resources, memory overcommitment is enabled by default in RHEL. With memory overcommit, you can assign more memory to virtual machines (VMs) than is available to the host. The RHEL kernel then automatically assigns memory to VMs that require it.
VMs running on the KVM hypervisor do not have dedicated blocks of physical RAM assigned to them. Instead, each VM functions as a Linux process where the host’s Linux kernel allocates memory only when requested.
The host’s memory manager can move the VM’s memory between its own physical memory and swap space. When memory overcommitment is enabled, the kernel can decide to allocate less physical memory than is requested by a VM, because often the requested amount of memory is not fully used by the VM’s process.
Note, however, that with frequent overcommitment for memory-intensive workloads, the system can still become unstable.
Memory overcommitment requires you to allocate sufficient swap space on the host physical machine to accommodate all VMs, as well as enough memory for the host physical machine’s processes.
Possible methods to deal with memory shortages on the host include the following:
- Allocate less memory per VM.
- Add more physical memory to the host.
- Use larger swap space.
A VM runs slower if it is swapped frequently. In addition, overcommitting can cause the system to run out of memory (OOM), which may lead to the Linux kernel shutting down important system processes.
Memory overcommit is not supported with device assignment. This is because when device assignment is in use, all virtual machine memory must be statically pre-allocated to enable direct memory access (DMA) with the assigned device.