Saturday, November 30, 2019

ubuntu - How can virtual machines consume so little RAM on the physical host machine?


I'm running VirtualBox on a Windows XP machine with 2GB RAM. I've created a virtual Ubuntu machine and allocated it a base memory of 750MB.


Just to put it to a test, I ran 20 things at once on the virtual machine. According to "top" in ubuntu, 750 megs of memory were being used, as well as considerable swap space.


However, back in Windows Task Manager, VitrualBox was using only 45,000K of memory. As I asked the virtual machine to do more and more, the CPU usage of the VirtualBox process went up (in Windows) but memory usage stayed the same.


How can a virtual machine that is using 750 MB of memory only consume 45 MB of memory on a physical machine?


I assume the answer is that the virtual machine is not using real memory, but simulated memory (i.e. swap space), but it sure feels snappy like it is running in RAM.


UPDATE: I've played around with perfmon as suggested. Even summing up everything I can think of, it still seems to take up less than 300 megs ... so it is still a mystery.


Process               VirtualBox     VirtualBox#1     Total
PoolNonpagedBytes 5,840 42,552 48,392
PoolPagedBytes 119,796 166,892 286,688
PrivateBytes 8,884,224 52,719,616 61,603,840
VirtualBytes 75,939,840 161,202,176 237,142,016
Sum 84,949,700 214,131,236 299,080,936

Answer



The columns in Task Manager can give misleading figures -- for accurate memory usage per process, you could use perfmon (Performance Monitor in Control Panel) and look at the "private bytes" figures.


To show this, go into perfmon, click to add the counter (I'm a Ctrl+I kind of person). The "Performance object" would be "Process", with "Private bytes" being in the counters list -- obviously you'd need to select the relevant process from the right hand list.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...