Out of memory error occurs in Linux Azure virtual machine
This article helps understand and troubleshoot an out-of-memory (OOM) error when using Linux Azure virtual machine.
Original product version: Virtual Machine running Linux
Original KB number: 4010058
On a Linux Azure virtual machine, you encounter an OOM error. For example, the System log shows the following error:
localhost kernel: Out of memory: Kill process 2154 (oom) score 844 or sacrifice child
This issue may be caused by the lack of a swap file.
Add a swap file to increase the virtual memory in Linux Azure virtual machines. To do this, follow these steps.
To create a swap file in the directory that's defined by the ResourceDisk.MountPoint parameter, you can update the /etc/waagent.conf file by setting the following three parameters:
ResourceDisk.Format=y ResourceDisk.EnableSwap=y ResourceDisk.SwapSizeMB= xx
The xx placeholder represents the desired number of megabytes (MB) for the swap file.
Restart the WALinuxAgent service by running one of the following commands, depending on the system in question:
Ubuntu: service walinuxagent restart Red Hat/Centos: service waagent restart
Run one of the following commands to show the new swap apace that's being used after the restart:
dmesg | grep swap swapon -s cat /proc/swaps file /mnt/resource/swapfile free| grep -i swap
If the swap file isn't created, you can restart the virtual machine by using one of the following commands:
shutdown -r now init 6
For more information, see Ubuntu Cloud Images and SWAP space in Windows Azure Virtual Machines running pre-built Linux Images.