A VM is configured to run with 8 Gb of memory. The guest OS reports that only 4 Gb is in use, and the host OS shows that
prl_vm_app consumes 8 Gb. Why does the
prl_vm_app process consume more memory than it is reported by the guest OS inside the VM?
It is one of the major differences between Virtual Machines and Containers. A Virtual Machine has its hardware virtualized, while a container shares same hardware with the Host (except for network interfaces, they are virtual of course).
When a process in the guest environment frees memory, the reaction from the host OS is different.
- For a container, the freed memory is added to the host's free memory because this is shared resource between the host OS and running containers.
For a virtual machine, memory pages are not shared with the host OS. Memory management is done by the guest OS within the allocated space of a
prl_vm_appprocess, it allocates maximum possible amount of memory which can be configured for a virtual machine, but it is allowed to use only specified amount of memory.
If some application in the guest environment modifies a page which is mapped to a previously unmodified page of the
prl_vm_appprocess, this page is marked as used in the guest OS and on the host OS side. When this memory is freed by the application, this freed memory is marked as free only for the guest OS, it is not removed from used resources of
This difference in memory management leads to the situation when both a CT and a VM might show the same results on startup - relatively small RAM usage.
However, if a VM runs considerable amount of time, at some point RAM usage spike will occur (modern OSes tend to use free memory for file cache) and this VM will use all the memory it is allowed to use which will turn memory from allocated to used from the host OS perspective. It might be freed on guest side shortly, but it will stay in use on the hardware node side.
To sum up - a VM can consume memory dynamically, but it cannot free memory dynamically. The only way to release such memory (freed on Guest and used on Hardware Node) at any given moment is to terminate the VM's
prl_vm_app process. It can be done either by suspending and resuming the VM, or by stopping and starting it.
- In event of memory overcommitment/shortage on the node, the guest OS with installed Guest Tools can get some memory locked by a balloon device (as described in the documentation), and a
prl_vm_appprocess could forcibly release host OS memory pages corresponding to the locked ones in the guest OS.
The memory is released from the guest in this way before suspending or creating a snapshot for a VM,
prlctl reset command will only power-cycle Guest OS, and won't restart a
prl_vm_app process, therefore it won't be helpful in this situation.
NOTE: pausing/resuming a virtual machine does not free memory, since the process is not terminated.