Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1848

Memory leak in Container.java due to thread pool: args remained in ThreadLocal

XMLWordPrintable

      In Container.invoke() at the beginning it is called
      EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
      so args are assigned to ThreadLocal inside EJBArgsPolicyContextHandler. But at the end of the method the ThreadLocal is not cleaned, so, due to thread pool, mi.getArguments() remains in memory untill next Container.invoke() for the given thread. Solution is to call
      EJBArgsPolicyContextHandler.setArgs(null);
      at the end of the method.
      "diff -c" follows

          • Container.java.orig Thu Mar 31 16:59:12 2005
          • Container.java Wed May 25 13:38:08 2005
            ***************
          • 919,928 ****
            // Restore the incoming context id
            contextID = SecurityActions.setContextID(contextID);
      • // Remove msg from ThreadLocal to prevent leakage into the thread pool
        if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { SOAPMsgPolicyContextHandler.setMessage(null); }

        }
        }

          • 919,933 ----
            // Restore the incoming context id
            contextID = SecurityActions.setContextID(contextID);

      if (mi.getType() == InvocationType.SERVICE_ENDPOINT)

      { + // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); + }

      + else
      +

      { + // Remove args from ThreadLocal to prevent leakage into the thread pool + EJBArgsPolicyContextHandler.setArgs(null); }

      }
      }

              starksm64 Scott Stark (Inactive)
              olegnitz Oleg Nitz (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: