[
https://jira.jboss.org/browse/JBPM-2919?page=com.atlassian.jira.plugin.sy...
]
Mauro Molinari updated JBPM-2919:
---------------------------------
Description:
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.
was:
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 when a call to
org.jbpm.JbpmConfiguration.popJbpmConfiguration() causes the list to become empty.
Memory leak because of
org.jbpm.JbpmConfiguration.jbpmConfigurationStacks not released
--------------------------------------------------------------------------------------
Key: JBPM-2919
URL:
https://jira.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
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.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira