All Products
Search
Document Center

:How do I handle OOM errors on a Linux instance?

Last Updated:Aug 05, 2025

This topic describes how to identify, analyze, and resolve Out of memory (OOM) errors on Linux instances.

Background information

OOM is a mechanism that the Linux kernel employs to forcefully release process memory to ensure system stability when the system is critically low on memory. When the system runs low on memory resources, numerous OOM error messages may appear in logs. This prevents the system from allocating sufficient memory space to programs or processes, which affects the normal operation of programs or data read/write operations of processes.

Causes

OOM errors frequently occur when you run programs on a Linux instance. This may occur due to the following reasons:

  • The Linux instance has insufficient resources to meet the memory requirements of the running programs, which triggers OOM errors.

  • The application code improperly uses memory, which triggers OOM errors.

Troubleshooting steps

Perform the following steps to troubleshoot OOM errors:

  1. View OOM-related logs.

    In most cases, you can run the following commands to view Linux system logs.

    sudo less /var/log/messages
    sudo less /var/log/syslog

    Search for the keyword oom or kill in the logs to view information about OOM errors. If OOM events are caused by business applications, you can further locate the causes of OOM errors through business application logs.

  2. Check the current memory usage of the system.

    1. You can use the top or free command to check the memory usage of the Linux instance. For more information, see What do I do if the memory usage of a Linux instance is high?

    2. You can also use CloudMonitor to view memory metrics of the host. For more information, see Operating system monitoring.

Suggestions

Based on your troubleshooting results, you can choose the corresponding solution.

Cause

Suggestion

The Linux instance has insufficient resources to meet the memory requirements of the running programs.

Upgrade the memory configuration of the instance.

Warning

When you change the instance type of a subscription instance, you must restart the instance. To minimize impacts on your business, we recommend that you perform the operation during off-peak hours.

The application code improperly uses memory.

Optimize the application code, such as implementing paging for batch query requests.

References