cpu time division (time division), the operating system, there are many threads, each thread running time is determined by the cpu, cpu will give each thread a time slice, the time slice is a short length of time, if at the time chip, the thread has been occupied, it is 100%; we should be aware, cpu running very fast (very high frequency), unless consuming cpu-intensive operations, the other type of task will end in less than the time slice of time.
Produced CPU100% of reasons:
A program has been a cause of CPU CPU100%, about the following situations:
1、Java 内存不够或溢出导致GC overhead问题, GC overhead 导致的CPU 100%问题;
2、死循环问题. 如常见的HashMap被多个线程并发使用导致的死循环, 或者死循环;
3、某些操作一直占用CPU
The first step: Use the top command to view the process takes cpu
[root@sdfsdfseZ codeimage]# top
Step two: ps -ef | grep java or jps command to find all java process server
The third step: to find the most powerful CPU consumption process pid
Step Four: Find a specific occupation cpu utilization of the most powerful thread number, top -H -p pid. Then press shift + p, out of the monitoring CPU
The current thread number: 1747
Step 5: get to the thread number converted to hexadecimal
Because the thread id java thread stack files in hexadecimal, we need to thread id decimal to hexadecimal. Decimal turn hexadecimal command as follows:
The results are:
Step Six: Export thread stack
The CPU-specific excessive java process thread stack export, export command as follows:
pid.tdump arbitrary file extensions, usually tdump the end.
[root@sdfsdfsdeZ codeimage]# jstack 1747 > tmp/1747.tdump
You may throw exceptions;
1747: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
Cause Analysis
jvm runtime will generate a directory hsperfdata_ $ USER ($ USER is to start the process of java user), the default is / tmp in linux, some will pid file directory, store jvm process information, and jmap, jstack and other tool reads / pid files in tmp / hsperfdata_ $ USER get connection information.
Check the / tmp / hsperfdata_root project ,, but temp directory $ TOMCAT_HOME directory has a corresponding file.
Solution
To
Or
[root@iZ2zeab8t820b5ywp0rkfeZ bin]# jstack 1706 > /tmp/hsperfdata_root/1706.tdump
Step Seven: Export heap
[root@sddsdfsaZ bin]# jstat -gcutil 1706
Step eight: jvisualvm Analysis Snapshot
Use JAVA_HOME / bin / jvisualvm.exe, loaded Snapshot
File -----> Load -> File Types (Dump)
MAT can also be used to analyze memory.