Virtual machine uses double the allocated ram on the host

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
simion
Posts: 4
Joined: 1. Nov 2023, 03:41

Virtual machine uses double the allocated ram on the host

Post by simion »

VBox 7.0.12 running on Sonoma 14.1. Virtual machine is Windows 10 Pro 22H2
I have noticed that VirtualBox allocates twice the memory on the host system as allocated in the virtual one. For example, if I allocate 2GB for the virtual machine, VBOX will take 4GB of real memory from the host (plus about 512MB for vbox itself which is normal) . If I allocate 4GB for the virtual machine, VBOX will take 8.5GB of real memory from the host system, and so on.

I know this was a bug that was fixed in 6.1 release. I've seen this issue on every version of 7.0 since the initial release. Is this a known issue? I tried searching for a open issue list but keep getting a bad gateway error on the site right now.

Thanks in advance for any info.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Virtual machine uses double the allocated ram on the host

Post by mpack »

Please provide a VM log file. Make sure the VM is fully shut down, then right click it in the manager UI. Select "Show Log" and save "VBox.log" (no other file) to a zip file. Attach the zip here.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtual machine uses double the allocated ram on the host

Post by fth0 »

simion wrote: 1. Nov 2023, 03:55 I know this was a bug that was fixed in 6.1 release.
No, it was never accepted as a bug in VirtualBox (see 19726#comment:35 for the gory details).
simion wrote: 1. Nov 2023, 03:55 I've seen this issue on every version of 7.0 since the initial release.
In VirtualBox 7.0, there are no kernel extensions any more. In consequence, it looks even more like macOS doubly counts the memory allocated only once by VirtualBox.
simion
Posts: 4
Joined: 1. Nov 2023, 03:41

Re: Virtual machine uses double the allocated ram on the host

Post by simion »

Thank you for the replies. The requested zipped log file is attatched.

Below is the output from 'top' showing 4601MB ram usage for a 2GB windows 10 virtual machine

Code: Select all

PID   COMMAND      %CPU  TIME     #TH   #WQ  #PORT MEM    PURG   CMPRS  PGRP PPID STATE    BOOSTS          %CPU_ME %CPU_OTHRS UID  FAULTS    COW    MSGSENT
8300  VirtualBoxVM 46.7  01:27.45 32    2    464   4601M  284K   0B     8300 8299 sleeping *0[8]           0.00000 0.00000    501  1475532+  1203   9970+
I did see this behavior in 6.1 but it was resolved in later releases (I unfortunately don't remember the release that fixed it).
Windows 10 BASE-2023-11-01-19-00-17.log.zip
(51.9 KiB) Downloaded 442 times
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtual machine uses double the allocated ram on the host

Post by fth0 »

Windows 10 BASE-2023-11-01-19-00-17.log wrote:
00:00:01.406193   RamSize           <integer> = 0x0000000080000000 (2 147 483 648, 2.0 GiB)
[...]
00:00:01.406486   VRamSize         <integer> = 0x0000000010000000 (268 435 456, 256.0 MiB)
[...]
08:36:43.569745 /PGM/Page/cAllPages                591415 count
The provided memory sums up to: 2.0 GiB + 256.0 MiB = 2048 MiB + 256 MiB = 2304 MiB.

The allocated memory sums up to: 591,415 * 4 KiB = 2,365,660 KiB = ~2,310 MiB.
simion
Posts: 4
Joined: 1. Nov 2023, 03:41

Re: Virtual machine uses double the allocated ram on the host

Post by simion »

Thanks for that quick analysis! This is a perplexing problem. Unfortunately, I'm not sure how it was resolved under 6.1. It's difficult to think this is an issue on the macos side as I don't see a doubling of RAM usage on applications other than virtualbox. In fact office suite, Firefox, 3rd party open source apps, etc have similar memory foot prints when running natively on windows machines as they do on the mac. In case the logs don't show this, I did not mention that I am using an Intel based Mac if that might make any difference.

If there is any other log or information you may need, please feel free to ask. Thanks again for your time!
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtual machine uses double the allocated ram on the host

Post by fth0 »

simion wrote: 1. Nov 2023, 03:55 I know this was a bug that was fixed in 6.1 release.
simion wrote: 2. Nov 2023, 15:25 I'm not sure how it was resolved under 6.1.
Well, I don't remember anything that has been done to "resolve" this behavior, which the VirtualBox developers never accepted as a VirtualBox problem. It would be interesting to know what you know. ;)
simion wrote: 2. Nov 2023, 15:25 I don't see a doubling of RAM usage on applications other than virtualbox.
Type 2 hypervisors like VirtualBox need a special type of memory that is not allowed to be paged out, and which is different from the memory types used by most other applications. For example, on a Windows host, you cannot even see the memory allocated by VirtualBox in the Windows Task Manager (so-called Driver-Locked memory). You could try if another type 2 hypervisor (e.g. VMware Fusion) shows the same behavior.
simion
Posts: 4
Joined: 1. Nov 2023, 03:41

Re: Virtual machine uses double the allocated ram on the host

Post by simion »

Well, as a plain old user and not being as versed in software development as you are, I can only report on my experience that the last few versions of 6.1 did not have this problem on my system (I do remember seeing it way earlier on in 6.1 releases and just dealt with it at the time). Anyway, thanks for your time.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtual machine uses double the allocated ram on the host

Post by fth0 »

Thanks for reporting back, and you're welcome! :)
Post Reply