Back to Legacy KVM Documentation

    Cannot Allocate Memory Error

    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.

    Common Error Message

    Cannot allocate memory

    The Solution: Create 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.

    Why This Happens

    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.

    Common Scenarios

    System Updates

    Package managers may require significant memory

    Compilation

    Building software from source can be memory-intensive

    Database Operations

    Large queries or imports may exceed available RAM

    Application Installation

    Installing new software packages

    Quick Fix

    The quick solution is to run these commands via SSH:

    Create swap space
    swapoff /dev/vda2
    mkswap /dev/vda2
    swapon /dev/vda2

    After creating swap, try your operation again. It should now complete successfully.

    Preventing Future Issues

    To ensure swap is always available after reboots, add this line to /etc/fstab:

    /etc/fstab entry
    /dev/vda2  none  swap  sw  0  0

    Note for Cloud Users

    This issue is specific to SolusVM KVM VPS. Cloud instances typically handle swap configuration automatically.

    Still Having Issues?

    If you continue to see memory errors after creating swap space, you may need to:

    Upgrade VPS

    Consider a plan with more RAM

    Increase Swap

    Use GParted ISO to resize swap partition

    Optimize Apps

    Reduce memory usage of running services

    Need Help?

    Contact our support team if you need assistance diagnosing memory issues or upgrading your VPS.