Virtual box and memory management

Discussions related to using VirtualBox on Windows hosts.
Post Reply
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Virtual box and memory management

Post by NA! »

From the usage of VBox 5.0 series (this was not the case with vbox 4), i got the impression that if you have a virtual machine and have allocated i.e. 2GB RAM to it, this amount of memory is not immediately reserved upon machine startup but it's rather dynamically allocated when the virtual machine actually requests it. Since i usually have some programs open (browser, mail) when i start a virtual machine with WinXP, this dynamic allocation method has caused the machine to start, show the XP logo and right at the point where it has shown the blue background (graphical) screen and supposed to show the login screen, VBox crashes apparently because of low memory (as i've seen in the logs). If for instance i close the browser or restart it to free some memory and then start vbox again, everything seems to work fine.

If indeed my impression is correct and VBox dynamically allocates memory upon startup, perhaps this decision should be revisited.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual box and memory management

Post by mpack »

NA! wrote:From the usage of VBox 5.0 series (this was not the case with vbox 4), i got the impression that if you have a virtual machine and have allocated i.e. 2GB RAM to it, this amount of memory is not immediately reserved upon machine startup but it's rather dynamically allocated when the virtual machine actually requests it.
That would be a wrong impression I believe.

Disk space is dynamically allocated, not RAM. RAM can be shrunk down after the VM has started (when ballooning is enabled), but AFAIK you still need that RAM to start the VM.

Nothing has changed in this regard between v4 and v5.
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

mpack wrote:Disk space is dynamically allocated, not RAM. RAM can be shrunk down after the VM has started (when ballooning is enabled), but AFAIK you still need that RAM to start the VM.
Hmmm. Then i guess this behavior i'm describing is strange. Where do i find ballooning-related settings?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual box and memory management

Post by mpack »

Ramshankar
Oracle Corporation
Posts: 793
Joined: 7. Jan 2008, 16:17

Re: Virtual box and memory management

Post by Ramshankar »

You can force pre-allocation of the entire guest RAM on VM startup if you *really* require such a behaviour but be aware that this can slow down starting up of the VM (as allocating gigs of memory might take a while) and in NOT the recommended thing to do:

Code: Select all

VBoxManage setextradata <vmname> VBoxInternal/RamPreAlloc 1
Oracle Corp.
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

Thanks for the info. I've faced this crash this morning, at startup. Since i had just the browser open (which means there was no low memory issues - i have 6GB total RAM), i guess i may have stumbled upon some weird bug and it's not a memory issue. I'll post a bug report with the logs so that someone can check it.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual box and memory management

Post by mpack »

I suggest that you post the log here, since I doubt that a bug is involved. This sounds like a typical case of something on the host being locked in the middle of available memory, thereby preventing a very large RAM allocation.

With the VM fully shut down, right click it in GUI. Select "Show Log" and save "VBox.log" (ONLY) to a zip file. Attach the zip here.
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

I'm not sure any more that it's a memory issue. I have 6GB total ram and i have allocated 1.5 on the virtual machine. Upon startup this morning, i started just the browser on the host (400 MB RAM - yes, Firefox with some addons takes that much) and then vbox and it crashed. It shouldn't have a memory problem.

I'm attaching the log file here, which i copied after the crash (with the VM off) directly from the VM's Logs subfolder.
VBox.zip
(17.13 KiB) Downloaded 139 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual box and memory management

Post by mpack »

You don't have 6GB available. You have 6GB total, 2.3GB available.
VBox.log wrote: 00:00:02.554312 Host RAM: 6091MB total, 2331MB available
...
00:00:02.972999 RamSize <integer> = 0x0000000060000000 (1 610 612 736, 1 536 MB)
...
00:00:02.973355 VRamSize <integer> = 0x0000000008000000 (134 217 728, 128 MB)
You clearly have one or more memory hogs on your system, before the VM runs.
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

mpack wrote:You don't have 6GB available. You have 6GB total, 2.3GB available.
Well, yes, i didn't say i had 6GB avail, i said 6GB total. So it seems that 2331-1536 - 128 = 667 MB is not enough memory for VBox to properly startup the VM? I wonder what's happening though. When the VM starts up, VBox reserves the 1536 + 128 MBs for the VM but it (perhaps temporarily) needs some RAM for itself, which happens to be more than 667MBs, so it crashes?

Strange i had never experienced this crash and in general this behavior in VBox 4. For now, i'll lower the VM's RAM to 1GB (at some point i had it to 2 GBs and i lowered it to 1.5 to see if the crash would occur again). Let's see what happens...

From the logs, is there any chance there's another problem, not memory related?
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

OK, after some tests, i've gathered the following data:

- Loading all applications at startup (have in mind this is a developer's PC), Task Manager and Resource Monitor report the available memory to be ~3500 MB but the Free memory to be about 1600 MB. There is a lot (>1500MB) Standby memory. After starting the VM (with 1GB allocated ram), the Free memory is reported to be 0. The In-Use memory jumps from 2.something to 4GBs. The VM did not crash.

Increasing the memory of the VM to 2GB causes the crash. The error message that appears is "The instruction at 0xd946b07f referenced memory at 0x00000000. The memory could not be read".

Apart from adding more memory to the PC, i wonder if there's something i could do to minimize the amount of "standby" memory, which seems to be a lot and i don't understand if it's actually available or not. From what i understand, this is cache memory which i assume it should be available to the system when required, right?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual box and memory management

Post by mpack »

I assume you're asking about a host OS feature. I imagine that "standby memory" refers to RAM which is currently being used for non-vital purposes, such as a huge disk cache, and which can be freed should the need arise.
NA!
Posts: 63
Joined: 29. Jun 2012, 10:02
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows (XP, 7, 10), Linux

Re: Virtual box and memory management

Post by NA! »

mpack wrote:I assume you're asking about a host OS feature. I imagine that "standby memory" refers to RAM which is currently being used for non-vital purposes, such as a huge disk cache, and which can be freed should the need arise.
That's right. I'm making the same assumption too but it seems that the host OS is not giving this memory to VBox so even though it seems there's about 3GBs free, actually only 1.something is given to VBox. Anyway, it seems that 6GBs are not enough. Time for an upgrade. :)

Thanks for the help.
Post Reply