Fault: Recently received the production server alarm sms and mail, the alarm content is: Memory utilization is higher than 70%.
Use the top command to view system resource Usage, command:top
You can see that the process memory usage of Java is high, and the memory utilization of Java process reaches 70%+
2. Locating threading issues (viewing the thread condition of the 9718 process by command), command:PS P 9718-l-o pcpu,pmem,pid,tid,time,tname,cmd
From this you can see that this pid:9718 process produces a lot of threads. Next, you can view the memory-used stack through Jstack.
3. View the memory-used stack: Here we pick the tid=9720 thread for analysis, first we need to convert the ID 9731 to 16 binary. You need to enter the following command
printf "%x\n" 9731
You need to use the 16 binary 2603
4. Print the stack information for PID 9718 to Jstack.log, command:jstack-l 9718 > Jstack.log
5. View stack information file, command: Vim Jstack.log
The search for TID is 2603 related information.
You can see that the thread status is: Waiting. see a large number of Java Thread state by looking at file analysis .
It indicates that it is waiting for another condition to happen, to wake itself up, or simply that it is called sleep (N).
At this point the thread state is roughly the following:
Java.lang.Thread.State:WAITING (parking): Always wait for that condition to happen;
Java.lang.Thread.State:TIMED_WAITING (parking or sleeping): timed, that condition does not come, also will wake themselves regularly.
6. Code optimization: Send files to development. Optimize the thread
Java process consumes high system memory, troubleshooting