Hi,
When I launch a VM and there isn't enough free memory on the host, VirtualBox pauses the VM and gives an error. I've noticed that the host's swap file isn't used to allocate the missing memory. Why?
Why doesn't VirtualBox allocate memory from the host's swap?
-
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Why doesn't VirtualBox allocate memory from the host's swap?
Because actual, physical, non-swappable memory must be used.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
-
- Volunteer
- Posts: 1095
- Joined: 20. May 2009, 02:17
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Windows, OSX
- Location: U S of A
Re: Why doesn't VirtualBox allocate memory from the host's swap?
so that the guest OS may do its own paging/swapping if it is capable
Re: Why doesn't VirtualBox allocate memory from the host's swap?
Please could you elaborate? I would be interested in knowing why.socratis wrote:Because actual, physical, non-swappable memory must be used.
-
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Why doesn't VirtualBox allocate memory from the host's swap?
There's nothing to elaborate on. The memory needs to be locked in order to reduce latency and to prevent paging and swapping, which are really, really slow processes.
If your host runs out of memory, close some applications on the host, buy more RAM for the host, or reduce the amount of RAM assigned to the guest.
Read the following threads. They actually deal with the same problem as yours:
If your host runs out of memory, close some applications on the host, buy more RAM for the host, or reduce the amount of RAM assigned to the guest.
Read the following threads. They actually deal with the same problem as yours:
- Reasons of vm to get into "aborted" state,
- Virtual box and memory management, and most importantly
- What happens if I exceed my RAM? (especially Ramshankar's answer).
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Re: Why doesn't VirtualBox allocate memory from the host's swap?
Thank you both for your answers.
The threads you've linked discuss immediate versus gradual memory allocation, but they don't touch the subject of swapping. Sure, swapping is slower but isn't it better than crashing the VM?
The threads you've linked discuss immediate versus gradual memory allocation, but they don't touch the subject of swapping. Sure, swapping is slower but isn't it better than crashing the VM?
It shouldn't prevent the guest from swapping, even though I assume it could be very slow to swap on both the host and the guest simultaneously. Just a hypothesis.ChipMcK wrote:so that the guest OS may do its own paging/swapping if it is capable
Last edited by socratis on 28. May 2018, 11:08, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
Reason: Removed unnecessary verbatim quote of the whole previous message.
-
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Why doesn't VirtualBox allocate memory from the host's swap?
The threads that I linked to, talk about memory allocation in general, do not simply focus on the "when", but focus on the "why", the kind of memory that needs to be allocated.
What I was hoping that you'd get from those threads is that if you want to prevent your VM crashing mid-running, would be to force the allocation of the RAM when the VM starts, and not rely on the lazy memory allocation algorithm. That way you will know from the get-go that you don't have enough RAM on your host.
And no, swapping is not an option. There are some processes that require specific features from the allocated memory; VirtualBox requires the memory to be available and non-swappable.
What I was hoping that you'd get from those threads is that if you want to prevent your VM crashing mid-running, would be to force the allocation of the RAM when the VM starts, and not rely on the lazy memory allocation algorithm. That way you will know from the get-go that you don't have enough RAM on your host.
And no, swapping is not an option. There are some processes that require specific features from the allocated memory; VirtualBox requires the memory to be available and non-swappable.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.