How does VirtualBox's memory usage work?
To understand the process architecture of VirtualBox see
The VirtualBox architecture :
Once you start a virtual machine (VM) from the GUI, you have two windows (the main window and the VM), but three processes running. Looking at your system from Task Manager (on Windows) or some system monitor (on Linux), you will see these:
- VirtualBox, the GUI for the main window;
- Another VirtualBox process that was started with the -startvm parameter, which means that its GUI process acts as a shell for a VM;
- VBoxSVC, the service mentioned above, which is running in the background to keep track of all the processes involved. This was automatically started by the first GUI process.
As regarding memory, the User Manual states:
Base memory
This sets the amount of RAM that is allocated and given to the VM when it is running. The specified amount of memory will be requested from the host operating system, so it must be available or made available as free memory on the host when attempting to start the VM and will not be available to the host while the VM is running. This is the same setting that was specified in the "New Virtual Machine" wizard, as described with guidelines under the section called “Creating a virtual machine” above.
This means that the guest takes out of the host:
- As much memory as it was declared with
- Each VM is also a VirtualBox executable, so you need to add its memory.
It’s always possible that the VirtualBox manual is several versions behind, and that the latest memory optimizations technique are not documented.
In addition, VirtualBox may be optimizing memory usage by not allocating the entire defined VM memory.
Allocating memory as required is an optimization that can save a lot on physical memory, but memory-intensive processes in the VM may be slowed down by the frequent need by VirtualBox to request more host memory.
The only place in Task Manager that seems to reflect the full amount is on the performance tab - the Total Commit Charge value roughly keeps pace with the amount allocated to the VM. I just closed one with 1536MB allocated, and the commit charge went down from about 2.4GB to 0.8GB. You can monitor to some extent this against Virtual Box using the Performance Monitor, and choosing the Process : Private Bytes counters for VirtualBox, VBoxSvc, and also VirtualBox#1, #2, etc (one for each running VM). There's also the Memory : Committed Bytes counter for everything.
This looks to be a Windows problem. View the third post here: http://forum.sysinternals.com/pe-is-not-showing-all-memory-used-by-virtualbox_topic23886.html
Using a program like VMMap definitely does show that the memory you tell VBox to use is actually being used. No idea why it's not visible to task manager or process explorer.