[jira] Reopened: (JETTY-1167) GZipFilter cause OutOfMemoryError

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] Reopened: (JETTY-1167) GZipFilter cause OutOfMemoryError

JIRA jira@codehaus.org

     [ http://jira.codehaus.org/browse/JETTY-1167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simone Bordet  reopened JETTY-1167:
-----------------------------------


> GZipFilter cause OutOfMemoryError
> ---------------------------------
>
>                 Key: JETTY-1167
>                 URL: http://jira.codehaus.org/browse/JETTY-1167
>             Project: Jetty
>          Issue Type: Bug
>          Components: HTTP
>    Affects Versions: 6.1.21
>         Environment: Windows 2003 Server
> Java 1.5.0u17
>            Reporter: Michael Slattery
>            Assignee: Simone Bordet
>             Fix For: 6.1.23
>
>
> An OutOfMemoryError within GzipFilter.  It happens randomly on a production system, but I can't reproduce it in my development environment.
> {noformat}
> java.lang.OutOfMemoryError
> at java.util.zip.Deflater.init(Native Method)
> at java.util.zip.Deflater.<init>(Deflater.java:121)
> at java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:46)
> at org.mortbay.servlet.GzipFilter$GzipStream.doGzip(GzipFilter.java:525)
> at org.mortbay.servlet.GzipFilter$GzipStream.<init>(GzipFilter.java:417)
> at org.mortbay.servlet.GzipFilter$GZIPResponseWrapper.newGzipStream(GzipFilter.java:392)
> at org.mortbay.servlet.GzipFilter$GZIPResponseWrapper.getOutputStream(GzipFilter.java:342)
> {noformat}
> _My diagnosis:_
> This is actually caused by the *C heap* running out of memory.
> The gzip filter creates GZipOutputStream objects, but doesn't call close() as that would close the underlying socket stream.  GZipOutputStream calls out to C code which uses the C heap. If GZipOutputStream objects aren't cleaned up by GC fast enough (so finalized can be called), it's possible that the C heap can run out of memory.
> This is a known issue in the JVM:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4797189
> http://markmail.org/message/zflsen5q2uchpas3
> _A possible solution:_
> * Extend GZipOutputStream to free up C memory when {{finish()}} is called.
> * Modify {{doGZip()}} to instantiate the extended class instead of GZipOutputStream
> {code:title=GZOutput.java}
> class GZOutput extends GZipOutputStream {
>   GZOutput(OutputStream out, int size) throws IOException { super(out, size); }
>   public void finish() {
>     super.finish();
>     def.end();  //protected java.util.zip.Deflater
>   }
> }
> {code}
> We did something similar to the above, but we did it in a more complicated way to avoid having to modify Jetty source.
> This doesn't entirely fix the issue; {{finish()}} is never called when an exception is caught in {{doFilter()}} and {{isCommitted()}} is {{false}}.  Perhaps {{wrappedResponse.finish()}} should be called in the catch, but I'm not sure.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email