Does virtualbox support hot adding memory?

5

1

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.

BCoates

Posted 2012-07-10T18:16:39.227

Reputation: 195

Answers

3

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.

soandos

Posted 2012-07-10T18:16:39.227

Reputation: 22 744

2

While vbox doesn't strictly support memory hot-add, it DOES support ballooning: http://www.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 – 2012-07-10T18:24:36.880

@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 – 2012-07-10T18:27:53.770

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 – 2012-07-10T18:33:03.900

@allquixotic, unfortunately the host is OSX. Added that to the question. – BCoates – 2012-07-10T18:47:01.553

@BCoates, if the swapfile in on an SSD, thrashing is basically meaningless, and don't worry about. – soandos – 2012-07-10T19:01:12.730