a backend server with the OS of slackware 8.1 and tomcat 4.1.30 is installed. It often crashes during busy periods. The dead state is "Java. lang. outofmemoryerror: Unable to create new Native thread ". Tomcat cannot create a new thread to respond to the request. So I set up an environment to test this problem. The memory is 2 GB, the CPU is 4 2.8 GB, and tomcat 4.1.30. Write a simple JSP page, as shown in the following figure:
Code
<%
try
{< br> thread. sleep (30000);
out. println ("fuck");
}catch (interruptedexception e) {
E. printstacktrace ();
}< BR >%>
Then press jmetor, and enable jconsole to monitor tomcat, and continuously adjust the xmx, XMS, and XSS parameters. The following table is displayed:
Number of Tomcat threads when xmx xms xss is down
500 m 500 m 128 K 642
800 m 800 m 64 K 485
1024 M 1024 M 64 K 374
1024 M 1024 M 128 K 374
1024 M 1024 M 512 K 371
According to this table, we can see that with xmx, the larger the memory size allocated to JVM, the smaller the number of threads that Tomcat can open, and the XSS parameter hardly affects any test results. I guess Tomcat uses Linux memory instead of JVM memory for thread opening. The larger the memory allocated to the JVM, the smaller the memory that the operating system can allocate, and the smaller the number of threads that can be opened.
Do you have any solutions? Have you ever encountered this problem? My idea is that each initial Linux Process (that is, the Tomcat thread) has an initial size. This should be a Kernel Parameter. You can just tune it down, but I don't know how to adjust it.