dev@glassfish.java.net

Re: one more memory leak risk

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 20 Feb 2009 09:29:00 -0800

Hi Roman,

On 02/20/09 05:30 AM, Roman Pokhodzhai wrote:
> Thanks, I'll post it
>
> Though, my previous issues were ignored as well. But they are
> critical. Without fixing them I can't say that Glassfish is PRODUCTION
> server.

Thanks for filing the issue!

Notice that it has been fixed in GlassFish v2.1 and GlassFish v3
Prelude, as part of the fix for
https://glassfish.dev.java.net/issues/show_bug.cgi?id=6416

The fix was to wrap StandardHostValve#postInvoke in a try/finally, where
the finally
block restores the container's classloader as the thread context
classsloader, like this:

    try {
        ...
    } finally {
        Thread.currentThread().setContextClassLoader
            (standardHostValveClassLoader);
    }

I will go ahead and close the bug you filed as a duplicate of IT 6416.
I hope this is ok with you.

Thanks!

Jan

>
> On Fri, Feb 20, 2009 at 3:25 PM, Alexis Moussine-Pouchkine <alexis.mp
> <http://alexis.mp>@sun.com <http://sun.com>> wrote:
>
> Hello Roman,
>
> Thanks for your email.
> I think filling an issue is a better way to have someone look into
> this.
>
> thanks,
> -Alexis
>
>
> On Feb 20, 2009, at 10:58, Roman Pokhodzhai wrote:
>
> BTW, It's actual for Glassfish V2 ur1/ur2
>
> On Fri, Feb 20, 2009 at 10:05 AM, Roman Pokhodzhai
> <rpohod_at_gmail.com <mailto:rpohod_at_gmail.com>> wrote:
> Hi , All,
>
> I found defect in code which provoke PermGen memory leak problem.
> org.apache.catalina.core.StandardHostValve.postInvoke(). If
> response is committed the context class loader of the current
> thread (which is set to the application class loader in
> org.apache.catalina.core.StandardHostValve.invoke()) is never
> unset. This causes a thread to hang on to our application
> class loader even after the application is undeployed.
>
>
> public void postInvoke(Request request, Response response)
>
> // START SJSAS 6374691
>
> throws IOException, ServletException
>
> // END SJSAS 6374691
>
> {
>
> // START SJSAS 6374990
>
> if (((ServletResponse) response).isCommitted()) {
>
> return;
>
> }
>
> // END SJSAS 6374990
>
>
> HttpServletRequest hreq = (HttpServletRequest)
> request.getRequest();
>
> // END OF IASRI 4665318
>
> // Error page processing
>
> response.setSuspended(false);
>
>
> Throwable t = (Throwable)
> hreq.getAttribute(Globals.EXCEPTION_ATTR);
>
>
> if (t != null) {
>
> throwable(request, response, t);
>
> } else {
>
> status(request, response);
>
> }
>
>
> Thread.currentThread().setContextClassLoader
>
> (standardHostValveClassLoader);
>
>
> // START SJSAS 6374691
>
> if (errorReportValve != null) {
>
> errorReportValve.postInvoke(request, response);
>
> }
>
> // END SJSAS 6374691
>
> }
>
>
>
>
> Any suggestions?
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> <mailto:dev-unsubscribe_at_glassfish.dev.java.net>
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
> <mailto:dev-help_at_glassfish.dev.java.net>
>
>