Memory Panoramic Analysis

Updated at:

Scans and breaks down memory usage when overall consumption is high but the source is unclear. The diagnostic report provides pie charts of system and application memory distribution and ranks the top 30 consumers of application memory, file cache, and shared memory.

Limits

  • Region Limits

    Available only in the Chinese mainland and China (Hong Kong) regions.

  • Permission Limits

    If you use a Resource Access Management (RAM) user, ensure that your Alibaba Cloud account has granted the AliyunECSReadOnlyAccess and AliyunSysomFullAccess system policies to the RAM user.

  • Operating System Limits

    Architecture

    Operating System

    x86 architecture

    • Rocky Linux 9.5

    • Rocky Linux 9.1

    • Ubuntu 20.04

    • Alibaba Cloud Linux 3 Container-Optimized Edition

    • Rocky Linux 8.8

    • Ubuntu 22.04

    • Alibaba Cloud Linux 3 Pro

    • Alibaba Cloud Linux 2 or 3

    • CentOS 7.6 or later, or CentOS 8

    • Anolis OS 7 or 8

    • Ubuntu 24.04

    ARM architecture

    • Alibaba Cloud Linux 3 Pro

    • Alibaba Cloud Linux 3

Procedure

  1. Log on to the Cloud Monitor 2.0 console, select the target workspace, and in the left-side navigation pane, click All Features.

  2. On the All Features page, click CloudLens for ECS.

  3. At the top of the page, click System Diagnosis (SysOM).

  4. For Diagnosis Mode, select Node Diagnosis. From the Type of diagnosis list, select Memory Diagnostics. From the Diagnostic Item list, select Memory Panoramic Analysis. Select the target Instance ID and then click Execute Diagnosis.

  5. In the Diagnosis Records area, click View Report.

Diagnostic Report

  • Basic information

    Shows the instance ID (or resource ID), diagnosis item, diagnostic report ID, and diagnosis start time.

  • Diagnosis Conclusion

    Shows detected memory usage anomalies, if any.

  • Diagnosis Suggestions

    Provides troubleshooting suggestions for abnormal memory usage.

  • Diagnosis Details

    • Memory Usage Analysis

      Three pie charts showing the distribution of total, kernel-mode, and user-mode memory usage.

    • Application Memory Usage Sorting

      Top 30 tasks by memory consumption, showing task name, total memory usage, user-mode memory (Anon), and file memory (File).

    • File Cache Consumption Sorting

      Top 30 files by cache consumption, showing file name, cached size, and associated task. The task field is empty if no task is associated.

    • Shared Memory Cache Consumption Sorting

      Top 30 files by shared memory cache consumption, showing file name, cached size, shared memory type, and associated task. The task field is empty if no task is associated.

Practice Cases

Cloud-native containerized deployments abstract infrastructure but can reduce memory visibility at the container engine layer, leading to memory blackholes, high memory usage, memory leaks, latency jitter, and cgroup leaks. Memory Panoramic Analysis attributes cache and shared memory usage within systems and containers to specific files, making memory maintainable, testable, and traceable.

High Container Working Set in Kubernetes Environments

Kubernetes monitors container memory through working sets. If a container exceeds its memory limits or a node experiences memory pressure, Kubernetes may evict or terminate the container based on its working set.

Note

Working Set = Anonymous memory + active_file

Anonymous memory is allocated through methods such as new, malloc, or mmap. active_file memory is consumed when a process reads or writes files. Because programs often use file-backed memory opaquely, it can be difficult to trace.

Problem Description

Container monitoring detected a continuous increase in the working set memory of a pod, but the application's own memory usage showed no significant increase. The root cause of the working set growth could not be identified.

Diagnosis Analysis

Use Memory Panoramic Analysis to diagnose the ECS node where the pod resides and view the diagnostic report.

The diagnosis revealed that the business program was creating and writing log files to the container's /var/log directory, generating excessive file cache. This drove the pod's working set memory to its limit, triggering direct memory reclamation and blocking business processes.

Solution

Based on the diagnosis, resolve the high memory usage as follows:

  • Run the following command to release the cache.

    sudo sh -c 'echo 1 > /proc/sys/vm/drop_caches'
  • If the cache files are not essential, delete them manually to free space.

  • Use the memory QoS feature of ACK clusters.