]
Alejandro Guizar updated JBPM-2919:
-----------------------------------
    Fix Version/s: jBPM 3.2.10
                       (was: jBPM 3.2.x)
 Memory leak because of
org.jbpm.JbpmConfiguration.jbpmConfigurationStacks not released
 --------------------------------------------------------------------------------------
                 Key: JBPM-2919
                 URL: 
https://issues.jboss.org/browse/JBPM-2919
             Project: jBPM
          Issue Type: Bug
      Security Level: Public(Everyone can see) 
          Components: Runtime Engine
    Affects Versions: jBPM 3.2.7
            Reporter: Mauro Molinari
            Assignee: Alejandro Guizar
            Priority: Critical
              Labels: configuration, jbpm3, memory_leak, threadlocal
             Fix For: jBPM 3.2.10
   Original Estimate: 0 minutes
          Time Spent: 1 hour, 20 minutes
  Remaining Estimate: 0 minutes
 When class org.jbpm.JbpmConfiguration gets initialized by the class loader, a static
variable named jbpmConfigurationStacks gets initialized. This is a ThreadLocal, and so it
gets registered in the java.lang.Thread.threadLocals map of the calling thread.
 However, if jBPM is embedded into a web application, this means that that variable is
registered on one of the HTTP threads of the application server. When the web application
shuts down, the mapping is not removed, because there's no code in jBPM that takes
care of this task.
 Fortunately, the value of this thread local is of type ArrayList, which is a class which
is surely loaded by the root class loader, so no references to the webapp class loader are
retained. However, Tomcat 6.0.28 still says the following:
 SEVERE: The web application [/webappname] created a ThreadLocal with key of type
[org.jbpm.JbpmConfiguration.StackThreadLocal] (value
[org.jbpm.JbpmConfiguration$StackThreadLocal@26fe26cc]) and a value of type
[java.util.ArrayList] (value [[]]) but failed to remove it when the web application was
stopped. This is very likely to create a memory leak.
 A fix could be to do a remove() on that ThreadLocal whenever a call to
org.jbpm.JbpmConfiguration.getJbpmConfigurationStack() is made and an empty array is
returned or produced (except for the push operation, of course). This means to change the
following methods:
 - org.jbpm.JbpmConfiguration.popJbpmConfiguration()
 - org.jbpm.JbpmConfiguration.getCurrentJbpmConfiguration()
 - org.jbpm.JbpmConfiguration.clearJbpmConfigurationStack() (not used?)
 A better fix would be to refactor this code a bit so that the thread local is never left
set if the "stack" is empty. 
-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: