This assumes you are using VirtualBox as your provider, which you are if you’re using a pre-built vagrant configuration like I am with VVV.
I was running out of RAM and crashing my VM while trying to import a 9MB WXR file into a WordPress install.
First, I tried adding a swapfile so I could get some virtual memory. I was able to do that with these instructions from Digital Ocean, but I wasn’t sure how to make it persistent after a vagrant destroy
and didn’t want to have to set this up every time I booted up the VM.
Finally, I found this thread in the issues for VVV with the answer.
Create a Customfile in the same directory as your Vagrantfile, and add the contents below, changing 2048 to be whatever value you want to increase your VM’s RAM to.
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 2048]
end
Save the file, and then do a vagrant reload
and you should be able to verify with top
or free -m
that you now have some additional memory in the VM.
I went with 2GB. There has been some discussion of increasing the default in VVV from 512MB, however I think that would be an issue for people on laptops, especially running MacBook Air’s with only 4GB of RAM.