[jboss-jira] [JBoss JIRA] (JBRULES-3303) Memory leak in RuleBaseEventSupport.listeners when loading StatefulKnowledgeSession - Test Attached

Thomas Swindells (Commented) (JIRA) jira-events at lists.jboss.org
Thu Dec 1 08:46:42 EST 2011


    [ https://issues.jboss.org/browse/JBRULES-3303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647082#comment-12647082 ] 

Thomas Swindells commented on JBRULES-3303:
-------------------------------------------

The bug appears to be org.drools.marshalling.impl.InputMarshaller.readSession(MarshallerReaderContext, int, ExecutorService, Environment, SessionConfiguration) line 204.

session.setKnowledgeRuntime(new StatefulKnowledgeSessionImpl(session));

The constructor for StatefulKnowledgeSessionImpl explicitly calls session.setKnowledgeRuntime. This creates a ProcessRuntimeImpl storing it in processRuntime. The processRuntimeImple  adds a knowledgebase listener to the knowledgebase.
The outer call then calls session.setKnowledgeRuntime for a second time. This recreates a new ProcessRuntimeImpl and blindly overwrites the  processRuntime field. The new processRuntime will register a new listener on the knowledge base. As the reference to the first processRuntime has been lost only the second listener is removed when the session is disposed.

The simplest solution would be to not explicitly call session.setKnowledgeRuntime.
A more robust solution would be to fix setKnowledgeRuntime to cope with being called multiple times.
                
> Memory leak in RuleBaseEventSupport.listeners when loading StatefulKnowledgeSession - Test Attached
> ---------------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-3303
>                 URL: https://issues.jboss.org/browse/JBRULES-3303
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core (flow)
>    Affects Versions: 5.3.0.Final
>         Environment: Linux, Java 1.6.0_24
>            Reporter: Greg Chrystall
>            Assignee: Mark Proctor
>         Attachments: mem-leak-test.tar.gz
>
>
> When loading a Drools Flow StatefulKnowledgeSession with JPAKnowledgeService.loadStatefulKnowledgeSession, AbstractEventSupport.listeners has 2 listeners added to it. When the StatefulKnowledgeSession is disposed() only 1 of the listeners is removed. In the attached test this causes 100 ReteooStatefulSession objects to stay alive.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list