[Turn] Java program CPU soared troubleshooting methods

Cpu soaring windows environment issues

Taiwan online a runtime machine (windows Server) cpu alarm, this is the initial code inside an infinite loop, the first machine off the assembly line to ensure that no new assignments coming in, but still not bring the cpu usage is normal because the program does not end the cycle of death it has been running.

  1. Find the java process corresponding to the pid. 
    Method to find the pid is: open the Task Manager, and then click the "View" menu, then click "Select Columns", the pid hook, then you can see the pid value of all processes in the Task Manager. (See tool may be directly mentioned in the third step), windows10 system can directly view the details 
    Operating Picture
  2. Export a snapshot of the Java process.

    jstack -l pid > c:/31372.stack

  3. Cpu utilization process can only be viewed in the windows, cpu usage To view the thread must rely on other tools, you can use Microsoft's  Process Explorer (Click to go to the download page)

  4. Right-click the process you want to view properties 
    View the process
  5. Then select the Threads tab, locate occupy cpu thread tid 
    View tid
  6. Pid converted to hexadecimal, I have here a direct conversion system comes with a calculator, why should place the conversion, because previously exported with jstack inside information corresponding to the thread tid is hexadecimal. 
    Hexadecimal conversion
  7. Then you can search 7C84 in the process of the exported file inside

Linux environment issues soared cpu

    1. Use the following command to find the most CPU-intensive process, and then click 1, you will be shown the number of parameters and now server logical CPU server CPU. Occupy the highest standing in the front, we can see the high occupancy ava process

      top -c

    2. Identify high occupancy Java thread, the thread running display a list of process information, click to view the highest occupied by P

      top -Hp pid

    3. Use JVM comes jstack command to export the current operating conditions and the current status of all threads threads, jstack tools can be used java stack and native stack information obtained core files, so you can easily know how java program is a program crashes and what problems at 

      jstack pid > error.log

    4. Target thread turn hex pid

      printf “%x\n” pid

    5. Find the position after the decimal conversion error.log in pid16

      grep pid error.log –color

Guess you like

Origin www.cnblogs.com/lyhero11/p/11408988.html