Take the 2-minute tour ×

I have an Ubuntu VM that's thrashing swap due to a small guest memory allocation on a host with lots of free ram. It appears the guest kernel is compiled to support hot-adding RAM, is there way to get virtualbox to mount more ram without shutting down the running VM?

I don't need zero downtime, I can do a state-save, but I don't want have to restart the multi-day processing job in progress on the guest.

Guest is Ubuntu 12.04, Host is OSX 10.7, both x64.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

VirtualBox does not support adding more memory in this fashion. However, in many cases it will still be worth it to restart the computation, because the speed may increase by a factor of a hundred or more by using RAM as opposed to a hard drive.

An important note, even if your VM is "thrashing" that does not mean that the RAM is not getting used by windows (caching the disk that the VM is using) and thus the thrashing is having little/no impact.

In order to find out if this is the case, then just check the speed of the operation, and see if there is a change (or was a change) when the "thrashing started" or if the amount of RAM that is taken up by the VirtualBox process is significantly more than amount of RAM the guest has.

share|improve this answer
While vbox doesn't strictly support memory hot-add, it DOES support ballooning: virtualbox.org/manual/ch04.html#guestadd-balloon . I would recommend to the OP to restart the VM -- just this once -- and overcommit way more memory than you think you'll need. Vbox should be smart about it and only use that extra memory if the guest demands it. Don't overcommit beyond the physical RAM, but you can go pretty close to physical RAM. Worst case, your host starts swapping, but it'll only start doing that if there is substantial memory pressure on the host, which is usually a good thing. –  allquixotic Jul 10 '12 at 18:24
@allquixotic, agreed, but that is not the focus of the question (as far as I can tell anyway). If the OP edits/comment to that effect, then I will add this idea to my answer (or feel free to post your own) –  soandos Jul 10 '12 at 18:27
The guest's swapfile is on an SSD mounted directly to the VM, not a virtual drive, so the host OS doesn't get a chance to cache it. The swapping only happens intermittently, when the guest is serving unrelated requests. This causes the processing to come to a near-halt until the other job finishes, but forward progress is still happening. –  BCoates Jul 10 '12 at 18:33
@allquixotic, unfortunately the host is OSX. Added that to the question. –  BCoates Jul 10 '12 at 18:47
@BCoates, if the swapfile in on an SSD, thrashing is basically meaningless, and don't worry about. –  soandos Jul 10 '12 at 19:01

Your Answer


