virtual memory exhausted: Cannot allocate memory

As a potential quick fix: You can reduce the memory usage by doing

make -j 1

which tells the build tool to use only one CPU. Worked for me.


Just add a swap file to solve this problem!

// Create a swap file 1 GB

  1. dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576
  2. chown root:root /swapfile1
  3. chmod 0600 /swapfile1
  4. mkswap /swapfile1
  5. swapon /swapfile1

// Edit fstab file

  1. vi /etc/fstab

//Append the following line at the end of file

  1. /swapfile1 none swap sw 0 0

// Check the swap is ready or not

  1. free -m