Page 1 of 1

Bypassing VM RAM limitation

Posted: 15. May 2011, 10:24
by Neolander
Hi everyone !

I have a computer with 4Gb RAM, and I'd like to run a VM with more than 3 GB of RAM on top of it. I don't care if the host starts swapping like crazy and the performance is terrible, it's just for experimental purposes. How can I bypass the "20% of system memory" limitation ?

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 10:28
by stefan.becker
Forget it, that cant work.

Else if its for testing. the host _MUST_ have RAM to work. For the host os, all services and for vbox as program.

You can only swap not used things.

But at 4 GB in sum and 3 GB for guest there is nothing useless.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 12:41
by HubTou
Hello,
Neolander wrote:I have a computer with 4Gb RAM, and I'd like to run a VM with more than 3 GB of RAM on top of it. [...] How can I bypass the "20% of system memory" limitation ?
You launch your VM from the command line (no 20% limitation) and, if needed, connect to its display using RDP or VNC.

On the machines i use, there's less than 160 Mb RAM allocated to the system, and the rest of the 24 to 48 Gb RAM is allocated to the VMs. However, i make sure that there's enough physical memory for the VM and that the swap is not used...

Best regards,

Hubert

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 15:45
by Neolander
Thank you very much, I'm going to try the CLI and see how well it goes :P

(I think that on a modern OS, CPU configuration tables, the memory manager, its data, and the pages of currently running code must be kept in RAM, but everything else can be swapped out. Now, of course, such a setup would run like absolute trash, because each time you reach a new page of code, access data, or switch to another process (through a scheduler that's not in RAM yet) you need to swap things in and out. But theoretically speaking, I think it works.

Anyway, I don't plan to go this extreme. Just something like 3.2-3.4 GB. I've seen in the past that most desktop linux distros still work well with 512 MB of RAM around.)

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 15:59
by Sasquatch
Just to be clear. You can't run a VM with more RAM than the Host has available and the Guest will be paused the moment Host RAM will be low. VB will not use swap space. So if you have 4 GB of RAM and the Host happens to use just 300 MB, the VM will not start if you set it to use 3,7 GB or more.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 16:02
by Neolander
Yeah, I've noticed it when I experimented with a setting that was a bit too high. It's not exactly that the VM did not start, but rather that X died when it tried to do so :)

I understand why a VM would want unswapped RAM, what I don't understand is why my Linux host can't swap tasks other than VB out, but well... I've seen what I wanted to see anyway.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 16:18
by Sasquatch
The reason your OS doesn't swap everything out, is because swap is a temporary location. Programs that aren't active, but still running will be swapped, but applications that aren't idle, will never be swapped. The CPU can only work on data that's in RAM, so in order to have a working computer, active data needs to be in RAM. The OS manages data transfers between swap and active RAM to avoid memory shortage and errors. But, as long as memory is not on short supply, nothing will be put in swap space. Running a VM will make the Host run out of active usable RAM and starts swapping inactive applications so the VM can still run. But once the limit is reached on how much can be swapped, it won't do anything anymore, else it would compromise data integrity and system stability.

Same idea as with a water fountain. You can take only that much out of the reservoir before the pump stops functioning.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 16:30
by Neolander
So no data belonging to an active process is ever swapped out ? Sounds strange... I'd have imagined that if pages of data have not been recently used by a given process, the operating system could consider that they are not in the working set anymore, mark the pages as absent, and swap them out in order to make some room...

Let's imagine a scenario where a large game or media application is running on a computer that is a bit lacking as far as RAM is concerned. What happens when the software has filled up the available RAM and wants to load more data ? Does it crash ? I thought that swapping was invented in order to address this kind of problems...

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 17:01
by Sasquatch
You are correct about that. That is what I was trying to say, it swaps inactive parts. But for some applications, there is no inactive memory or it's programmed to not be allowed to be paged. Games are a different story. They have parts where it's set to load, like when you go from one region to another. That's when the current region is unloaded and the new one is loaded. You probably also noticed some small hickups during play, which means that you hit a few parts that were put in swap during loading and is restored to RAM on demand.

But, this is actually off-topic.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 17:40
by Neolander
Totally off-topic indeed, but was an interesting discussion nonetheless :) I love learning about - and discussing - OS theory.

Re: Bypassing VM RAM limitation

Posted: 15. May 2011, 18:54
by Technologov
All standard software can use 'swap' - but VirtualBox is different. It is very complex piece of software, that is almost like mini operating system in complexity, and it uses 'vboxdrv' driver. Drivers are usually not swapped to disk, and so VirtualBox is programmed that way.

Very few software products approach the complexity of VirtualBox.

do:
# lsmod | grep vboxdrv
-or-
# modinfo vboxdrv