Executing Rules via SwitchYard results in a high number of Stateful Session remain in memory

Solution In Progress - Updated -

Issue

In our Switchyard project, we are using the rules component to execute some Drools rules against the input data. In our testing environment, we have observed a memory leak when running this service for some time. Eg, after 11.000 requests, a heap dumps shows the following issue:

Class Name                                                                                                    
--------------------------------------------------------------------------------------------------------------

org.jbpm.runtime.manager.impl.factory.InMemorySessionFactory @ 0xb12b9e40                                     
|- <class> class org.jbpm.runtime.manager.impl.factory.InMemorySessionFactory @ 0xb15a6ac0                    
|- environment org.switchyard.component.common.knowledge.config.builder.patch.PatchedRuntimeEnvironmentBuilder
|- kbase org.drools.core.impl.KnowledgeBaseImpl @ 0xb124c380                                                  
|- sessions java.util.concurrent.ConcurrentHashMap @ 0xb12b9e58                                               
|  |- <class> class java.util.concurrent.ConcurrentHashMap @ 0xaeb61520 System Class                          
|  |- table java.util.concurrent.ConcurrentHashMap$Node[16384] @ 0xb552bf38                                   
|  |  |- <class> class java.util.concurrent.ConcurrentHashMap$Node[] @ 0xaeb611d0                             
|  |  |- [1] java.util.concurrent.ConcurrentHashMap$Node @ 0xb24c6a80                                         
|  |  |- [3] java.util.concurrent.ConcurrentHashMap$Node @ 0xb24c8170                                         
|  |  |  |- <class> class java.util.concurrent.ConcurrentHashMap$Node @ 0xaeb61238 System Class               
|  |  |  |- key java.lang.Long @ 0xaeea9b60  3                                                                
|  |  |  |- val org.drools.core.impl.StatefulKnowledgeSessionImpl @ 0xb24c8190                                
|  |  |  |  |- <class> class org.drools.core.impl.StatefulKnowledgeSessionImpl @ 0xb2469918                   
|  |  |  '- Total: 3 entries                                                                                 
|  |  |- [0] java.util.concurrent.ConcurrentHashMap$Node @ 0xb2525168                                        
|  |  '- Total: 25 of 11,001 entries; 10,976 more                                                            
|  '- Total: 2 entries                                                                                       
'- Total: 4 entries                                                                                          
--------------------------------------------------------------------------------------------------------------

As this heap dump extract shows, we see one instance of the org.drools.core.impl.StatefulKnowledgeSessionImpl class per rules invocation (here: 11.001 entries). These instances are held by the org.jbpm.runtime.manager.impl.factory.InMemorySessionFactory.sessions map.

How can we dispose the StatefulSession instances to avoid this memory leak?

Environment

  • Red Hat JBoss Fuse
    • 6.2.1
    • 6.3.0
  • Integration Pack for Red Hat JBoss Fuse and BxMS

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content