tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilya goberman <gober...@msn.com>
Subject Memory leak in Tomcat 7?
Date Wed, 12 Jan 2011 22:08:24 GMT

Greetings,
Today I have encountered a nasty memory leak problem with Tomcat 7.0.4. The problem does not
exist in Tomcat 6.
This is the most basic Servlet functionality. Can someone confirm it is broken?

I wrote a simple Servlet that sends data. The client just makes the call to the Servlet and
issues a new call when the current call has completed. So it essentially calls the Servlet
in the loop.
After running it for a minute, Tomcat generates a message:

Jan 12, 2011 3:59:55 PM org.apache.tomcat.util.net.NioEndpoint$SocketProcessor run
SEVERE: 
java.lang.OutOfMemoryError: Java heap space
    at org.apache.tomcat.util.buf.CharChunk.allocate(CharChunk.java:119)
    at org.apache.tomcat.util.buf.CharChunk.<init>(CharChunk.java:83)
    at org.apache.catalina.connector.InputBuffer.<init>(InputBuffer.java:162)
    at org.apache.catalina.connector.InputBuffer.<init>(InputBuffer.java:146)
    at org.apache.catalina.connector.Request.<init>(Request.java:252)
    at org.apache.catalina.connector.Connector.createRequest(Connector.java:795)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:386)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:373)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1526)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Jan 12, 2011 3:59:55 PM org.apache.tomcat.util.net.NioEndpoint checkParachute
SEVERE: SEVERE:Memory usage is low, parachute is non existent, your system may start failing.
Jan 12, 2011 3:59:55 PM org.apache.tomcat.util.net.NioEndpoint checkParachute
SEVERE: SEVERE:Memory usage is low, parachute is non existent, your system may start failing.

The Servlet code is below:

public class WebFrameworkServletScriptStreaming extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
        response.setHeader("pragma", "no-cache,no-store");
        response.setHeader("cache-control", "no-cache,no-store,max-age=0,max-stale=0");
        
        response.setContentType("text/json");

        PrintWriter out = response.getWriter();
        
        for (int i = 0; i < 1000; i++) {
            out.print("push('{\"foo\":\"bar\"}');");
        }
    }
}

This is the client - use FF:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
    <title>test</title>
</head>
<body">
    <input type="button" value="TEST" onclick="test(); return false;" />

    <script type="text/javascript">
        var id = 0;

        function test() {
            var head = document.getElementsByTagName('head')[0];
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.onreadystatechange = function () {
            };
            script.onload = function () {
                head.removeChild(script);
                // LOOP!!!
                test();
            };
            script.onerror = function () {
                head.removeChild(script);
            };
            script.src = 'http://172.16.16.250/Test/Controller?test=' + (id++);
            head.appendChild(script);
        }

        function push(json) {
        }
        
    </script>

</body>
</html>



 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message