Troubleshooting memory allocation errors on KVM VPS
If you're seeing "cannot allocate memory" errors when running updates on your KVM VPS, the issue is typically caused by missing swap space.
This error occurs when your VPS runs out of available memory during operations like system updates. The solution is to create swap space, which acts as additional virtual memory.
Follow our detailed Missing Swap guide to create your swap space.
SolusVM KVM templates sometimes don't configure swap space correctly during initial setup. Without swap, your VPS can only use its allocated RAM. When operations require more memory than available RAM, you'll see memory allocation errors.
Package managers may require significant memory
Building software from source can be memory-intensive
Large queries or imports may exceed available RAM
Installing new software packages
The quick solution is to run these commands via SSH:
swapoff /dev/vda2
mkswap /dev/vda2
swapon /dev/vda2After creating swap, try your operation again. It should now complete successfully.
To ensure swap is always available after reboots, add this line to /etc/fstab:
/dev/vda2 none swap sw 0 0This issue is specific to SolusVM KVM VPS. Cloud instances typically handle swap configuration automatically.
If you continue to see memory errors after creating swap space, you may need to:
Consider a plan with more RAM
Use GParted ISO to resize swap partition
Reduce memory usage of running services
Contact our support team if you need assistance diagnosing memory issues or upgrading your VPS.