Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-2919

Memory leak because of org.jbpm.JbpmConfiguration.jbpmConfigurationStacks not released

XMLWordPrintable

      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.

              aguizar_jira Alejandro Guizar (Inactive)
              mauromol_jira Mauro Molinari (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 20 minutes
                  1h 20m