Today, my colleagues from the Xin Energy Testing Group asked me to see a strange phenomenon. A tomcat application has only a simple jsp page, and this jsp page does not have any java code (I want to use this jsp page to test the maximum QPS of a tomcat on her server). However, after using loadrunner for a few minutes, the tomcat, which allocated 1024M heap memory, actually packaged heap space outofmemory! The code for this page is as follows:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:///TR/html4/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>
</head>
<body>
<p>hello world!</p>
</body>
</html>
The initial analysis was that if a JSP page is stuck, a corresponding java file will be generated, and the java file will be compiled into a class file and loaded into memory. That is, there will be a class object that will be loaded into PermGen space. It has nothing to do with heap space. But the last thing that reports is an overflow to the space. So I guess that an object will be generated every time the jsp page is requested.
I searched on Baidu and found that every time I requested a JSP page, a session object will be generated. There is a configuration in tomcat:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
That is to say, every time a jsp page is requested, a session object will be generated, and this object will expire after 30 minutes. We calculated that the QPS at that time was 5000, which means that 5000 session objects were generated per second. 300K objects are generated per minute. The session is a map object, which is relatively large, which will quickly burst the memory.
The solution is as follows:
1. Add session=false to the page directive.
2. Set the expiration time of the session to 0.
Now her loadrunner runs very stably. I have never used jsp again after working, so it is still quite laborious to check jsp problems