Bug 50685

Summary: Big memory leak
Product: Tomcat 7 Reporter: Nicolai <tnik_28>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: major CC: zlelik2000
Priority: P2    
Version: 7.0.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Nicolai 2011-01-29 03:49:04 UTC
1) Download apache-tomcat-7.0.6-windows-x86.zip and unzip to C:\apache-tomcat-7.0.6 . But this bug with all tomcat versions.
2) Create simple jsp C:\apache-tomcat-7.0.6\webapps\ROOT\test.jsp :
AAA<%=7+8%>
3) Add SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_23\ to C:\apache-tomcat-7.0.6\bin\startup.bat  and run startup.bat
4) Open http://localhost:8080/test.jsp in browser - it works and shows AAA15.
5) Do 100000 requests to http://localhost:8080/test.jsp. Create new c# windows forms app. Put one button with code:

private void button1_Click(object sender, EventArgs e)
{
  StringBuilder sb = new StringBuilder();
  byte[] buf = new byte[8192];
  for (int i = 0; i < 100000; i++)
  {
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:8080/test.jsp");
    using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    using (Stream resStream = response.GetResponseStream())
    {
      string tempString = null; int count = 0;
      count = resStream.Read(buf, 0, buf.Length);
      if (count != 0) tempString = Encoding.ASCII.GetString(buf, 0, count);
    }
  }
}

6) It takes 15 seconds - test success. But tomcat process java.exe used 5mb memory before test, after test 270mb. If run test again java.exe take 286mb and crashed: Exception in thread ""http-apr-8080"-exec-2" java.lang.OutOfMemoryError: Java heap space ....

7) run MemoryAnalyzer. It shows 2 problem:
One instance of "org.apache.catalina.session.StandardManager" loaded by "org.apache.catalina.loader.StandardClassLoader @ 0x7f00638" occupies 3,112,280 (56.61%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$HashEntry[]" loaded by "<system class loader>".

The classloader/component "org.apache.catalina.loader.StandardClassLoader @ 0x7f00638" occupies 637,728 (11.60%) bytes. The memory is accumulated in one instance of "java.lang.Object[]" loaded by "<system class loader>".
Comment 1 Mark Thomas 2011-01-29 07:09:45 UTC
Please use the users mailing list if you require further advice.
Comment 2 Z@ 2014-02-05 08:43:01 UTC
(In reply to Mark Thomas from comment #1)
> Please use the users mailing list if you require further advice.

Hello,
Could you please explain why this bug is resolved or maybe it was moved to another place? If so, please give me a link to correct one.
Comment 3 Mark Thomas 2014-02-05 09:13:58 UTC
The bug was resolved as invalid because there is no bug here. If you do not understand why this bug is invalid, please ask on the users mailing list.
Comment 4 Z@ 2014-02-05 10:37:20 UTC
(In reply to Mark Thomas from comment #3)
> The bug was resolved as invalid because there is no bug here. If you do not
> understand why this bug is invalid, please ask on the users mailing list.
Hello,
How can I ask on the users mailing list? If I send email to dev@tomcat.apache.org system answer me that email cannot be delivered. I send it from email, which I used for registration on the issues.apache.org. I could not found on this website, how to subscribe on the users mailing list.
Comment 5 Daniel Baktiar 2014-02-05 15:10:21 UTC
@Z, you should send email to users-subscribe@tomcat.apache.org to subscribe.
Comment 6 Konstantin Kolinko 2014-02-05 15:14:23 UTC
1. This page has links:
http://tomcat.apache.org/bugreport.html#Bugzilla_is_not_a_support_forum

2. I added a comment on the original issue to the FAQ page here:
http://wiki.apache.org/tomcat/OutOfMemory