0

I have been using Virtual-Box off and on for 4 years now. A problem I have always had is that when you start a VM, Virtual-Box immediately takes the designated amount of RAM from my physical computer's overall RAM. Is there anyway to have Virtual-Box not take all the designated RAM at once? My current host OS is Linux Mint 19.3, and I have a VM with Windows 7 with 8 GB of RAM specified in Settings. I would like Virtual-Box to set aside about the same as the VM is using at that moment, is this possible?

Thanks in advance

LeMS_Studios
  • 1
  • 1
  • 2
  • I'm not certain what you want is possible. One alternative is to set up an ESXi host on another PC, and migrate the VM to it. This will reduce the load on your main PC. Also, ESXi can actually use just the lower amount, freeing up RAM for more VMs. – Christopher Hostage Mar 25 '20 at 17:53
  • It is not possible in VMware guests (that is what I use) and I do not think possible in Virtual Box. The memory is assigned initially to allow the guest to run. You need roughly 4 GB base plus 3 GB for each machine running total memory on your machine. – John Mar 25 '20 at 17:56
  • 1
    It's called "Memory ballooning" in VirtualBox lingo (see here: http://www.virtualbox.org/manual/ch04.html#guestadd-balloon), aka "Dynamic RAM" for the common folks, and it requires strict conditions to be implemented. Did I just post a comment or an answer? I'm confused. –  Mar 25 '20 at 18:11
  • @Didier - the reclaimed RAM can only be assigned to another VM though, it isn't returned to the host. – lx07 Mar 25 '20 at 18:31
  • @lx07: damn, I hadn't thought of that... :-( Apparently, it's a feature you can find in Hyper-V, but then it's MS-on-MS software, and it's not applicable to the OP's setup. Not even sure you could use Wine to run it on Linux, given how emmeshed it is with Windows. Sorry guys. –  Mar 25 '20 at 18:48

1 Answers1

0

You could add memory module zram to Your system by modprobe zram num_modules=1 and configure this /dev/zram0 device for having a share of Your RAM capacity.
So with starting a VM like VirtualBox it would take its defined amount of RAM capacity, but if it is above swap triggering level it would compress or (then have to) decompress parts of RAM content.

This might be a workaround for limited RAM capacity by increased cpu compression and decompression activity (if RAM shortage occurs) for "newer" cpu&memory&chipset systems.

( Examples for zram initializing script file: init-zram-swapping sets up less RAM than configured
and distribution of swap load: Is distributing load in a balanced way between swap partitions possible? )

VMware (on workstation) supports sharing memory between several VMs: https://www.vmware.com/support/ws5/doc/ws_performance_mem_host.html

beyondtime
  • 315
  • 2
  • 11
  • Sorry, but i can't comment yet. Hopefully this answer expands 3rd comment below user question https://superuser.com/questions/1535806/reduce-ram-usage-of-virtual-machine-in-virtual-box-to-amount-that-vm-is-actually/1537225#comment2330162_1535806 – beyondtime Mar 30 '20 at 17:21