When Tomcat starts in Linux, we simply check to see if the application is properly accessible to determine if Tomcat is booting properly. In general this is no problem, but sometimes we find that when Tomcat has been in use for a while, the CPU or memory surge begins to appear. At this point, looking at the Tomcat log may not be able to see the valid information, so it is necessary to understand the relevant tools provided by Linux and JDK.
1, view memory and CPU using a higher process information
Enter top and we can see the following information
2, if we want to see the PID 3583 process information, you can perform
Top-h-P 3582
Description: 3582 for the process ID, a process can have multiple threads. This basic knowledge of popular science to the small partners just getting started.
At this point, we can see the related thread information below process 3582. Threads that occupy more resources are ranked in the first few. OK, screenshot below.
3, since all found thread consumption information, but we have not found the reason. Don't worry, let's take a look at the stack information for a thread,
such as a thread with a PID of 3590. As for why to look at the stack of information, this does not need me to say more. If it is not clear, it is not expected to contact the Dongdong. OK, back to the point. To see the stack information for a Java thread, of course we have to use the Jstack tool that the JDK brings.
How to use:
Jstack [Process] | GREP-A 10 [Thread's 16-in-system]
-A 10 indicates that the following 10 lines of the row are found. 3590 Convert to 16 e06 with calculator, note that the letter is lowercase.
OK, let's execute the following command.
Jstack 3582|grep-a E06
After the execution, we will see the stack information as shown in the figure, at which point we will be able to make our own judgments with the information associated with thread prompts.