GCs Caused by Metaspace Expansion
- Perform profiling analysis on the target program and switch to the GC tab page.Invoke http://IP_address:9118/gctest/metaspace to trigger a GC event.Figure 1 GC tab page
It is found that some GCs are caused by Metadata GC Threshold and metaspace expansion.Figure 2 GC tuning suggestions
The memory usage of the metaspace and tuning suggestions are displayed. The cause is that the value of MetaspaceSize is too small or does not comply with the actual situation of the program.
- Increase the value of MetaspaceSize based on the tuning suggestions and then start profiling analysis.Figure 3 Overview
Figure 4 GC tab page
After MetaspaceSize is set to a larger value, GC caused by metaspace expansion does not occur.
- Summarize the tuning.
Although you do not need to worry about the insufficient memory of the original permanent generation after the metaspace is replaced with the permanent generation, the improper initial value of the metaspace may still cause performance problems to the JVM in some cases, especially for programs involving dynamic loading and unloading functions. It is necessary to set reasonable initial values of the metaspace for the program.
Summary
This practice describes how to use the Java Profiler to discover and resolve the GCs caused by System.gc() and metaspace expansion.
When tuning other programs, you need to perform tuning operations based on the analysis results collected by the Kunpeng DevKit and the corresponding tuning suggestions. For details about the tuning roadmap, see this practice.