All Products
Search
Document Center

:What do I do if the memory usage of a Linux instance is high?

Last Updated:Jun 19, 2025

Problem description

When you use a Linux ECS instance, the following issues may occur:

  • The system becomes unresponsive, service response times are long, and application performance is degraded.

  • High memory usage is displayed in the Elastic Compute Service (ECS) console. Memory usage that exceeds 80% is considered high.

  • Alerts are generated indicating that the memory usage exceeds the specified threshold.

Possible causes

The preceding issue may occur due to the following reasons:

  • Abnormal processes or services consume a large amount of memory.

  • The business traffic is too high, and the instance's physical memory is insufficient.

Troubleshoot the issue

Use top to check instance memory usage

Perform the following steps to resolve high memory usage issues:

  1. Connect to the ECS instance. For more information, see Methods for connecting to an ECS instance.

  2. Check for processes that consume a large amount of memory on the instance.

    View the CPU utilization and memory usage of processes.

    top
    Note

    To exit the top command, enter q.

    Press the M key to sort processes by memory usage. The following example output shows that the process with PID 13183 consumes the most memory.

    image

    The following table describes the system information summary and process metric fields.

    Fields in the system information summary and process list

    Fields in the system information summary

    Field (row)

    Description

    top

    The general information about the system.

    • The current time.

    • up: the system uptime.

    • user: the number of active users.

    • load average: the load average, which is the average queue length. The load averages for the previous 1, 5, and 15 minutes are displayed.

    Tasks

    The statistics of processes in different states.

    • total: the total number of processes.

    • running: the number of running processes.

    • sleeping: the number of sleeping processes.

    • stopped: the number of stopped processes.

    • zombie: the number of zombie processes.

    %Cpu(s)

    The statistics on CPU utilization.

    • us: the percentage of CPU time spent running user processes.

    • sy: the percentage of CPU time spent running kernel processes.

    • ni: the percentage of CPU time spent running user processes prioritized by using the nice command.

    • id: the percentage of time for which the CPU remains idle.

    • wa: the percentage of CPU time spent waiting for I/O.

    • hi: the percentage of CPU time spent servicing hardware interrupts.

    • si: the percentage of CPU time spent servicing software interrupts.

    • st: the steal time.

    MiB Mem

    The statistics on memory usage.

    • total: the total amount of physical memory.

    • free: the amount of available memory.

    • used: the amount of used memory.

    • buff/cache: the amount of memory used for kernel cache and buffers.

    MiB Swap

    The statistics on swap usage.

    • total: the total amount of swap space.

    • free: the amount of available swap space.

    • used: the amount of used swap space.

    • avail Mem: the total amount of cached swap space.

    Fields in the process list

    Field (column)

    Description

    PID

    The PID.

    USER

    The username of the process owner.

    PR

    The scheduling priority of the process. A smaller value indicates a higher priority.

    NI

    The priority specified by the nice command for the process.

    VIRT

    The amount of virtual memory used by the process.

    RES

    The amount of physical memory used by the process.

    SHR

    The amount of shared memory used by the process.

    S

    The process status.

    • R: running

    • S: sleeping

    • Z: zombie

    • D: uninterruptible sleep

    • T: traced or stopped

    %CPU

    The percentage of CPU usage by the process.

    %MEM

    The percentage of physical memory usage by the process.

    TIME+

    The total CPU time used by the process.

    COMMAND

    The command used to initiate the process.

Resolve the issue

The following table describes the causes of high memory usage issues and their solutions.

Problem description

Cause

Solution

A single user program or process consumes a large amount of memory for an extended period.

The program or process is abnormal.

  • Use the top tool to identify the PID of the program, and terminate the process by using one of the following methods:

    Warning

    Before terminating a process, make sure you understand the relevant information about the process to avoid business interruptions due to incorrect operations.

    • Run the sudo kill -15 <PID> command to terminate the process.

    • Terminate the process by running the top command in interactive mode. For more information, see Common Linux commands.

  • If you suspect that the process is malicious, scan and terminate it by using virus detection and removal.

A normal user program or process consumes excessive memory resources for an extended period of time.

The program is normal.

If the instance experiences memory resource bottlenecks, you can choose an appropriate method based on your business scenario:

A single business program or process occasionally occupies excessive memory resources for a short period.

The program or process has temporary traffic spikes or scheduled tasks that consume excessive memory resources within a short period of time.

No program or process consumes memory resources, but the overall memory usage is high.

Memory resources required for the normal operation of the instance's services exceed the instance's memory size.

If the instance has a memory bottleneck, change the instance type.

References