43

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:

  • I have a VM running Windows 7 (as the Guest OS) on my windows XP Host machine.
  • The Host Machine Has 3 GB of RAM
  • The Guest VM is setup to have a base memory of 1 GB
  • If I run Task Manger on the Guest OS, I see memory usage of 430 MB
  • If I run Task Manger on the host OS, I see 3 processes that seem to belong to VirtualBox:
    1. VirtualBox.exe (1), using 60 MB of memory (This one seems to have the most CPU usage)
    2. VirtualBox.exe (2), using 20 MB of memory
    3. VBoxSvc.exe, using 11.5 MB of memory
  • While running the VM, the Host OS's memory usage is about 2 GB
  • When I shut down the VM, the Host OS's it goes back to memory usage goes down to about 900 MB

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?

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?

Update:

Someone expressed distrust over my memory usage numbers, and I'm not sure if that distrust was directed at me, or my Host OS's Task Manager's reporting (which is perhaps the culprit), but for any skeptics, here is a screenshot of those processes on the host machine:

VirtualBox task manager

3
  • 1
    I was wondering the exact same thing earlier today when running two VBox VMs at once.
    – MartW
    Commented Nov 6, 2009 at 22:03
  • In Task manager, turn on some of the other memory columns (View->Select Columns...). Memory is counted in many different ways in Windows. For instance, "commit size" can be dramatically higher than "Memory Usage." Exactly which to use and how to interpret them is a different story.
    – lilbyrdie
    Commented Nov 6, 2010 at 14:43
  • Possible duplicate: superuser.com/q/17266/302 Commented Nov 7, 2014 at 14:23

7 Answers 7

13

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:

  1. VirtualBox, the GUI for the main window;
  2. Another VirtualBox process that was started with the -startvm parameter, which means that its GUI process acts as a shell for a VM;
  3. 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.

17
  • 8
    It's not VirtualBox specific - see this : serverfault.com/questions/19935/…
    – MartW
    Commented Nov 6, 2009 at 22:05
  • @harrymc, so what you are saying is that task manager does NOT show in the process list how much memory virtual box is using? Commented May 31, 2011 at 14:43
  • @TrevorBoydSmith: All I am saying is that there is more than one process involved and to choose correctly the columns in task manager.
    – harrymc
    Commented May 31, 2011 at 15:41
  • 3
    my vm takes up 1.2 GB. on task manager it only shows 60MB. so therefore i would claim that task manager doesn't show all the memory that my vm is using. unless you can somehow show me how to tweak task manager to show 1.2gb. Commented May 31, 2011 at 16:42
  • 1
    This entire conversation and all the answers are just variations on a confusion between virtual memory and physical memory. Commented Nov 2, 2015 at 11:33
12

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.

1
  • The OP doesn't seem to be particularly interested in what's been allocated though but is asking about what's being used. So I'm not sure how this relates to his question. Commented Nov 2, 2015 at 12:20
6

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.

2

Those entries you see in TaskManager are not for your virtual machine, they are for the VirtualBox GUI. The performance tab will clearly show you how much of your total memory is being used, but with no granularity regarding processes. I personally would like to see VBox use only what it needs, but agree it's important for it to be able to use as much as it expects, hence the ring-fencing.

2

You can see it using great SysInternals' application VMMap:

  1. First, you need to find the right process, so start for example Process Hacker or SysInternals' Process Explorer
  2. Display the list of processes as a tree (by clicking on the "Name" column header in the process list)
  3. Locate the process VBoxSVC.exe, it should have several child processes VBoxHeadless.exe if a VM is running
  4. 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
  5. 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
  6. Start VMMap
  7. 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.

1

Could be related to the VirtualBox Guest Additions.

My Ubuntu install is currently using ~20MB as reported by WinXP. This is with VBoxAdditions.

My Lubuntu install is currently using ~90MB as reported by WinXP. Just installed it; VBoxAdditions haven't been installed.

Memory usage does vary by what the VM is doing. I have my Ubuntu install running ziproxy; when I do something that talks to ziproxy, memory usage spikes a few megabytes as the VM comes into use.

In general, though, virtualization has advanced far enough that the specs apparent to the guest don't need to be wholly allocated from the host. Seems to use dynamic allocation, and strong paging.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .