Home » Questions » Computers [ Ask a new question ]

How does VirtualBox's memory usage work?

How does VirtualBox's memory usage work?

I've been running several VM's with VirtualBox, and the memory usage reported from various perspectives, and I'm having trouble figuring how much memory my VMs actually use. Here is an example:

Asked by: Guest | Views: 340
Total answers/comments: 3
bert [Entry]

"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."
bert [Entry]

"So clearly, there are some huge differences here. I really don't understand how the GuestOS can use 400+ MB, while the Host OS only shows about 75 MB allocated to the VM. Are there other processes used by VirtualBox that aren't as obviously named?

You're looking at what is being used on the host, not what is being allocated. The guest is not using 400+ MB of the host's RAM (yet).

Also, I'd like to know if I run a machine with 1 GB, is that going to take 1 GB away from my host OS, or only the amount of memory the Guest machine is currently using?

It will reserve 1GB of RAM, however it may wind up actually using significantly less than that. If the guest doesn't use some of that memory, host RAM can be used for many other purposes (such as caching clean disk pages), even though it's reserved for the guest. And even if the guest does use some of that memory, if it doesn't access it for sufficiently long, it can still get ejected from physical memory through opportunistic swapping.

Unfortunately, you've waded into an extremely complex issue and it would take many pages to really explain it. There is a lot of incorrect information in the answers to this question."
"So clearly, there are some huge differences here. I really don't understand how the GuestOS can use 400+ MB, while the Host OS only shows about 75 MB allocated to the VM. Are there other processes used by VirtualBox that aren't as obviously named?

You're looking at what is being used on the host, not what is being allocated. The guest is not using 400+ MB of the host's RAM (yet).

Also, I'd like to know if I run a machine with 1 GB, is that going to take 1 GB away from my host OS, or only the amount of memory the Guest machine is currently using?

It will reserve 1GB of RAM, however it may wind up actually using significantly less than that. If the guest doesn't use some of that memory, host RAM can be used for many other purposes (such as caching clean disk pages), even though it's reserved for the guest. And even if the guest does use some of that memory, if it doesn't access it for sufficiently long, it can still get ejected from physical memory through opportunistic swapping.

Unfortunately, you've waded into an extremely complex issue and it would take many pages to really explain it. There is a lot of incorrect information in the answers to this question."
bert [Entry]

"You can see it using great SysInternals' application VMMap:

First, you need to find the right process, so start for example Process Hacker or SysInternals' Process Explorer
Display the list of processes as a tree (by clicking on the ""Name"" column header in the process list)
Locate the process VBoxSVC.exe, it should have several child processes VBoxHeadless.exe if a VM is running
If multiple VMs are running, there will be multiple branches of VBoxHeadless.exe processes, pick the right branch by checking process' command line, it contains an identifier of your VM
You're interested in the inner-most VBoxHeadless.exe in the branch (i.e. it doesn't have any more children, just a parent, so it's a leaf), remember its PID
Start VMMap
Select the right VBoxHeadless.exe process by its PID and click OK

In my case, all reported Private bytes, Working set and Committed memory by VMMap almost exactly match the amount of memory assigned to the VM in VirtualBox."