How To enable and use Memory Ballooning

Discussions related to using VirtualBox on Linux hosts.
Post Reply
MandoesaM
Posts: 5
Joined: 22. May 2016, 13:50

How To enable and use Memory Ballooning

Post by MandoesaM »

Hi Folks,

I'm trying to configure memory ballooning in Ubuntu 14.04 using latest virtualbox 5.0.20, i created 2 VMs (Windows 7) each one has 512 MB Memory i want to set for each VMs to automatic increase memory to 1024 when needed.



Thanks in advance
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How To enable and use Memory Ballooning

Post by Perryg »

socratis
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: How To enable and use Memory Ballooning

Post by socratis »

I'm not sure that you completely understand how memory ballooning works. Please read Chapter 4.9, like Perry said. Thoroughly and carefully. Here is a small excerpt:
When memory ballooning is requested, the VirtualBox Guest Additions (which run inside the guest) allocate physical memory from the guest operating system on the kernel level and lock this memory down in the guest. This ensures that the guest will not use that memory any longer: no guest applications can allocate it, and the guest kernel will not use it either. VirtualBox can then re-use this memory and give it to another virtual machine.
So, if you have 512 for VM1 and 512 for VM2 you can't simply increase both to 1024. You have to "steal" from VM1 to "give" to VM2. And 512 for a Win7 guest is already too low.
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.
MandoesaM
Posts: 5
Joined: 22. May 2016, 13:50

Re: How To enable and use Memory Ballooning

Post by MandoesaM »

Hi socratis,

I agree with you that 512 is not enough for windows 7 but i'm in test lap the host have only 4GB Ram, so if win7-01 have 1024 and use only 700 MB so remain 300 MB will be added to the other vm ??

did i got your point ?


Thanks,
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How To enable and use Memory Ballooning

Post by Perryg »

If it were me I would use pagefusion instead.
socratis
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: How To enable and use Memory Ballooning

Post by socratis »

MandoesaM wrote:if win7-01 have 1024 and use only 700 MB so remain 300 MB will be added to the other vm ?
You're going to be starving your guest. I wouldn't suggest it. I would go with Perry's suggestion (Chapter 4.9.2). Do you have to run two Win7 guests at the same time?

@Perry
I can't test neither Memory Ballooning nor PageFusion, as they're not available on the Mac (my main host). Have you tried the latter? What can be the expected gains? Ball-park...
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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How To enable and use Memory Ballooning

Post by Perryg »

I have tried both and found pagefusion to actually allow for memory overcommitment if that is what one wants to call it with little to no effort on the user to actually manually change like ballooning does. It works fairly well as long as regressions don't get introduced. It has happened in the past but not that often. As far as I can tell you would need to try it to see just how much it will save you as it depends on the hosts ability and of course you need to have the proper guest additions installed, but it did a fair amount of saving the last time I used it ( don't do a lot with Windows these days ).
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How To enable and use Memory Ballooning

Post by Perryg »

I have just tested this again and while there is a savings it is minimal. However it may be that my build from the future is not actually using the feature or to its fullest potential. Ballooning or pagefusion I might add. The only way to be sure is for the OP to test it. Test was conducted on two Windows XP guests as I only have one Windows 7 guest and nothing newer. Since XP is no longer totally supported that could also have something to do with it.
MandoesaM
Posts: 5
Joined: 22. May 2016, 13:50

Re: How To enable and use Memory Ballooning

Post by MandoesaM »

hi guys,

thanks for replies, my manager asked me to test this feature as he want to run 3 VMs on the virtualbox and assign at least 4GB ram but he want to increase the ram size automatically if the application installed in the guest need to use more RAM,i did this with Hyper-V2012 R2 and works fine but he need virtualbox i'm confused on how i did it so guys please help me what i suppose to do and how can i ensure that it works after use the command in the manual.


i'm sorry again

Thanks in advance
socratis
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: How To enable and use Memory Ballooning

Post by socratis »

MandoesaM wrote:he want to run 3 VMs on the virtualbox and assign at least 4GB ram
In that case you'll need a host (physical system) with at least 16 GB RAM if you do not want any trouble.
MandoesaM wrote:he want to increase the ram size automatically if the application installed in the guest need to use more RAM
Can you imagine doing that to a physical computer? Install a RAM chip while your computer is running? I don't think so. Unless special provisions have been made (like installed the Guest Additions) you cannot do it on your generic VM.
MandoesaM wrote:i did this with Hyper-V2012 R2 and works fine but he need virtualbox
I had to read about that Hyper-V feature because I wasn't aware of it, I don't use Hyper-V. As far as I read, Hyper-V got this feature in Hyper-V R2 SP1 and for a limited number of guests, that have that capability already built-in.

It "seems" like the Memory Ballooning idea in VirualBox, but instead of using two VMs to pass memory back and forth, it uses the available host memory to dynamically increase the memory available to the guest. VirtualBox does not have a similar feature yet, so I'm afraid that you'll have to deal with that fact and plan accordingly.
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.
MandoesaM
Posts: 5
Joined: 22. May 2016, 13:50

Re: How To enable and use Memory Ballooning

Post by MandoesaM »

Hi socratis,
Thanks for trying to help me really i appreciate

Final Question i tried now in vm1 was assigned ram 1024 MB after applying command VBoxManage controlvm "VM name" guestmemoryballoon <n> i put memory value 500MB i noticed in Performance TAB in TASKManager that the memory usage decreased

so now plainly simply memory ballooning should navigate to other vm ?

with command VBoxManage modifyvm "VM name" --guestmemoryballoon <n> ??? if i used that command i got error

VBoxManage: error: The machine 'Win72' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 493 of file VBoxManageModifyVM.cpp
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How To enable and use Memory Ballooning

Post by Perryg »

You can not use modifyvm on a running guest. You would use controlvm instead as stated in the manual section posted.
MandoesaM
Posts: 5
Joined: 22. May 2016, 13:50

Re: How To enable and use Memory Ballooning

Post by MandoesaM »

Hello Perryg,

I'm sorry for many replies from my side about this matter, but i read the manual carefully many times, As I understand if i used (( VBoxManage controlvm "VM name" guestmemoryballoon <n>)) to shrink ram and share it to other VM if i wrong please correct me i do the following

1.Assign 1024 MB for first VM
2.apply command VBoxManage controlvm Win7pro guestmemoryballoon 400
3. i noticed that memory performance in task manager tab reduced to 646 MB


so my question how i can use the other available ram in VM1 to second VM


Thanks In advance
Post Reply