Question about VM memory

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Fritz

Well-Known Member
Apr 6, 2015
3,382
1,385
113
70
Virtualbox running on Ubuntu-MATE if it matters.

When a VM is running, does the memory assigned to it become unavailable to the host OS or is it allocated dynamically?

TIA
 

ttabbal

Active Member
Mar 10, 2016
747
207
43
47
In VirtualBox, I believe it is allocated at VM start and locked. KVM has memory ballooning, but the guest OS needs to support it.

Easy enough to test, allocate enough RAM to a couple VMs so that it can't load the second if you have the first running. Turn off swap "swapoff" should do it, and launch them. :)
 

Fritz

Well-Known Member
Apr 6, 2015
3,382
1,385
113
70
Not sure I understand "swap "swapoff"" but I allocated 8GB to each VM and they both started normally. System has a total of 16GB. Noticed no difference in the performance of the host system.
 

T_Minus

Build. Break. Fix. Repeat
Feb 15, 2015
7,640
2,057
113
Disable swap so you're not allocating "RAM" that's really from the disk.
 
  • Like
Reactions: Fritz

Fritz

Well-Known Member
Apr 6, 2015
3,382
1,385
113
70
Thanks. Just read a thread on another forum about this and the question never answered, just stupid advice like "Give your VM enough memory and you won't have to worry about swappyness" and other equally stupid answers. And the basic question was never answered "How you you disable swapping in Virtualbox?".

But it did just occur to me that maybe if I disable swapping within the VM that this might do it??

And thanks T_Minus, your answer answered my question.
 

Fritz

Well-Known Member
Apr 6, 2015
3,382
1,385
113
70
You wouldn't disable swap in VirtualBox. It would be something done on the host OS.
Yes sir, after more research I do believe you are correct.

ACK!!! after rereading the above i realized this is not correct. The host OS, being Ubuntu-MATE would have nothing to do with the VM's. I believe you meant it was done within the VM's. If not, please clarify.
 

BackupProphet

Well-Known Member
Jul 2, 2014
1,092
649
113
Stavanger, Norway
olavgg.com
Actually overcomitting memory on virtual machines is in many cases a good idea, It is not recommended to disable swap as you will just get "less" resources to play around with.

The reason overcommiting memory is good, is that you let the operating system decide what memory is "hot" and what is "cold". Though in many cases it can also be dangerous, especially on Linux. FreeBSD is much better, but its virtualization software Bhyve is still young. I have no idea about VMWare, but as a top tier enterprise product, I guess it performs excellent and is stable with overcommited memory.
 

T_Minus

Build. Break. Fix. Repeat
Feb 15, 2015
7,640
2,057
113
Actually overcomitting memory on virtual machines is in many cases a good idea, It is not recommended to disable swap as you will just get "less" resources to play around with.

The reason overcommiting memory is good, is that you let the operating system decide what memory is "hot" and what is "cold". Though in many cases it can also be dangerous, especially on Linux. FreeBSD is much better, but its virtualization software Bhyve is still young. I have no idea about VMWare, but as a top tier enterprise product, I guess it performs excellent and is stable with overcommited memory.
Couple things to keep in mind here though is that he's not running vmware and he's only disabling swap to test how virtualbox allocates memory. I don't see any issues with this, maybe I missed something though?
 

Fritz

Well-Known Member
Apr 6, 2015
3,382
1,385
113
70
By default, Virtualbox only allocates 4MB of memory to a new virtual machine. Can't see this being small amount being of much use in the real world. It's nice to know how it handles memory allocation. With 2 Win 7 VM's running with each having 8GB allocated to them, the second one to start was sluggish. But Ubuntu didn't seem to be affected at all. Don't quite understand why, maybe it has priority over the VM's?