Application memory leak troubleshooting
1. The origin of the article;
In the daily operation and maintenance process, you will encounter high server resources, CPU or memory problems caused by soaring oom lead service unavailable (most programs are java application), which prepared the article, is working to troubleshoot problems reference methods and quickly locate problems;
2. Basic knowledge base;
(1) .jvm common configuration parameters:
Heap Parameters
parameter |
description |
-Xms | The initial size of the heap memory setting JVM startup |
-Xmx | Set the maximum heap memory |
-Xmn | Set space to the young generation, the rest of the space for the older generation |
-XX:PermGen | Set the initial size of the permanent generation memory (JDK1.8 start permanent waste generation) |
-XX: MaxPermGen | Set the maximum permanent generation |
-XX:SurvivorRatio | Eden space ratio set region and Survivor region: Eden / S0 = Eden / S1 default 8 |
-XX:NewRatio | Set the old generation and the young generation ratio of the size, the default value is 2 |
Recovery parameters
-XX:+UseSerialGC |
Serial, young (younger area) and Old (tenured) are serial, using recycled copy algorithm, logic is simple and efficient, without context switching overhead |
-XX:+UseParallelGC | Parallel young (younger area) using Parallel scavenge collection algorithm, can generate multiple threads in parallel recovered. By -XX: ParallelGCThreads = n parameter specifies the number of threads have, by default cpu core number, Old (tenured): single-threaded |
As shown in the above table, at present there are serial, parallel and concurrent three kinds , large memory for application, serial low performance, the use of the main parallel and concurrent two kinds. Parallel and concurrent GC policies specified by UseParallelGC and UseConcMarkSweepGC, there are some details of the configuration parameters used to configure the implementation strategy. For example: XX: ParallelGCThreads, XX: CMSInitiatingOccupancyFraction like. Typically: Young target area selectively recovering only parallel (time-consuming), Old concurrent zone selection (consumption CPU).