The JVM monitoring feature of Application Real-Time Monitoring Service (ARMS) Application Monitoring provides a visual representation of various memory metrics over a specified time period. While these charts reflect times of high memory usage, they do not offer the detailed information you need to diagnose specific issues, which means they are not useful for troubleshooting problems like memory leaks or memory bloat. To do so, we recommend that you generate memory snapshots and analyze the detailed memory usage data in the logs.
Prerequisites
An ARMS agent for Java V2.7.1.2 or later that was released after September 24, 2021 is installed.
You are using the Linux system. Only Linux servers support memory snapshots.
Limitations
The memory snapshot feature is developed based on the built-in heap dumps of JVMs (jmap -dump:all). Heap dumps may require additional memory and trigger safe points and GCs that may suspend all non-JVM threads. As a result, applications are suspended, and this suspension cannot be interrupted. Therefore, it is essential to carefully evaluate the associated risks before enabling this feature in a production environment.
The memory snapshot feature is subject to the following dependency limitations:
ARMS agent V2.7.3.5 and earlier do not support JRE, Java 11, or Alpine Linux, and depend on the JAVA_HOME environment variable and the JAVA_HOME/lib/tools.jar file.
ARMS agent V2.8.3 to V3.2.8 support JRE, Java 8, Java 11, and Alpine Linux, and depend on the JAVA_HOME environment variable and Java commands. You must add
$JAVA_HOME/bin
to the PATH environment variable.In ARMS agent V3.2.9 and later, the memory snapshot feature is greatly optimized. You do not need to add
$JAVA_HOME/bin
to the PATH environment variable. Therefore, we recommend that you upgrade your ARMS agent to these versions. For more information about the upgrade, see Update the ARMS agent.
If the VPC network where the application is deployed is configured with a limit on the number of Object Storage Service (OSS) buckets that can be accessed, you must add the bucket that stores the memory snapshots to the corresponding policy. Format of the bucket: arms-heapdump-<regionId>. Replace <regionId> with the ID of the region. For example, if your application is deployed in the China (Hangzhou) region, the bucket name is arms-heapdump-cn-hangzhou.
NoteThe memory snapshot feature uploads the snapshot data collected by application instances to the specified OSS bucket for storage and processing. If you do not specify the OSS bucket in your policy, the data cannot be collected as expected.
Previously, historical snapshots had an unlimited retention period. However, beginning July 1, 2023, ARMS imposes a 90-day limit on the retention period of historical snapshots, which means you cannot save memory snapshots that you created more than 90 days ago. To avoid losing your data, we recommend that you regularly back it up.
Create a memory snapshot
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Application List page, select a region in the top navigation bar and click the name of the application that you want to manage.
NoteIcons displayed in the Language column indicate languages in which applications are written.
: Java application
: Go application
: Python application
Hyphen (-): application monitored in Managed Service for OpenTelemetry.
In the left-side navigation pane, click Application Details. On the page that appears, click the JVM monitoring tab.
In the upper-right corner of the JVM monitoring tab, click Create Memory Snapshot.
In the Create Memory Snapshot dialog box, select an IP address and click Save.
NoteIf you have selected an instance in the left-side navigation tree of the Application Details page, the IP address of the instance is automatically selected from the IP drop-down list.
In the message that appears, click Force to dump.
ImportantThe duration of a memory snapshot task varies from a few minutes to about half an hour. When you force a dump, the application process will stop responding, so proceed with caution.
View memory snapshot details
In the upper-right corner of the JVM monitoring tab, click Historical Snapshots.
The Number of Snapshot Jobs panel displays the task execution status. Green means that the snapshot task is successful, blue means it is executing, and red means it has failed. Find a task and click Details to view the progress of the task.
Find a task and click Analysis to view the analysis results in the Application Troubleshooting Platform (ATP) console.
FAQ
Why can't snapshots be automatically created and analyzed before an application encounters an OOM error?
When an application is about to encounter an out-of-memory (OOM) error, the system resource usage is usually quite high. Because creating a snapshot involves heavy resource consumption, automatically creating a snapshot at this time will likely trigger an OOM error. Therefore, we recommend that you take the following steps to create and analyze snapshots based on your business requirements:
Configure the following parameter for your application. When an OOM error occurs, the JVM automatically creates a memory snapshot in
/tmp/heap.bin
.In a Kubernetes environment, map the
/tmp/heap.bin
path to an external storage volume to prevent file loss caused by pod restarts.-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heap.bin
Upload the memory snapshot to an OSS instance. For more information, see Get started with OSS.
Use the ATP platform to analyze the memory snapshot.