1. Problem description

Fullgc alarms appear online every 5 minutes

2. Background

  1. The program executes system.gc ()
  1. The jmap-histo :live pid command is executed

  2. A series of checks that are performed during a MINOR GC

    When the Minor GC is performed, the JVM checks to see if the maximum contiguous free space in the old generation is greater than the total size of all objects in the current generation. If it is, the Minor GC is performed directly (at this point it is not risky to perform). If it is, the JVM checks to see if the space allocation guarantee mechanism is enabled, and if it is not, it simply performs Full GC instead. If enabled, the JVM checks to see if the maximum contiguous available space in the old age is greater than the average size for successive promotions to the old age, and if so, performs Full GC instead. If it is greater, a Minor GC is performed, and if the Minor GC fails, a Full GC is performed

  1. Large objects are used
  1. A reference to an object is held in a program for a long time

3. Troubleshooting procedure

Note that a STOP the Word event occurs during a JVM dump operation, which means that all user threads are suspended.

3.1 Obtaining the Dump File using JVM Parameters
# 1. If you need to add the following JVM parameters to the startup script, it will automatically dump fullGC
-XX:HeapDumpBeforeFullGC
# 2. In conjunction with the first JVM argument, specify a path to save the dump file for troubleshooting purposes. The path can also be relative-xx :HeapDumpPath= Absolute path for saving dump filesIf you add these two JVM parameters and the file is not dumped, it is possible that there are other parameters in your JVM parameters that cause the dump failure. If there are any parameters, remove them
-XX:+DisableExplicitGC
Copy the code
3.2 Using the JDK tool Jmap to obtain the dump file
Dump dump file
jmap -F -dump:live,file=jmap.hprof [PID] 

##### 3.3 Download the dump file from an online host to a local PCCommand format: SCP local_file remote_username@remote_ip:remote_folder or SCP local_file remote_username@remote_ip:remote_file or SCP Local_file remote_IP :remote_folder or SCP local_file remote_IP :remote_file##### 3.4 Use the jVisualVM tool of JDK or download jProfiler to analyze dump files

##### 3.5 The most important point is to download the dump files at the fullGC occurrence time and the dump files at the normal fullGC occurrence time to the local, and then compare, observe and analyze the dump files to find the cause of the problemCopy the code