A rear end server,os for Slackware 8.1, installed Tomcat 4.1.30, in the recent busy times will often panic, death is "java.lang.OutOfMemoryError:unable to create new native Thread ". It is tomcat that cannot create new threads to answer requests. So I set up a special environment to test this problem. Memory for 2G,CPU for four 2.8g,tomcat 4.1.30, write a simplest JSP page, as follows:
Code
<%
try
{
Thread.sleep(30000);
out.println("fuck");
} catch (InterruptedException e) {
e.printStackTrace();
} %>
Then open jmetor to pressure, while opening jconsole to monitor the situation of Tomcat, and constantly adjust the XMX,XMS,XSS three parameters, the following table:
XMX XMS XSS down时的tomcat thread数
500M 500M 128K 642
800M 800M 64K 485
1024M 1024M 64K 374
1024M 1024M 128K 374
1024M 1024M 512K 371
According to the table, the larger the amount of memory that is allocated to the JVM, the smaller the number of thread that tomcat can open with Xmx, and the XSS parameter hardly affects any test results. I guess the tomcat thread is using Linux memory, not the JVM's memory. The larger the memory allocated to the JVM, the smaller the memory the operating system can allocate, and the smaller the number of threads that can be opened.
Do you have any solutions? Have we never met this problem? My assumption is that Linux initially each process (that is, tomcat open thread) has an initial size, this should be a kernel parameter, it should be small on it, but I do not know how to tune.