Compiled resource objects leak in BRMS KnowledgeAgent
Environment
- Red Hat JBoss BRMS
- 5.3.1
Issue
OutOfMemoryErroris presented in a BRMS application which hasKnowledgeAgentlooking at DRL files in a directory and those files are sometimes updated. In the heap dump,multiple org.drools.rule.DialectRuntimeRegistry/org.drools.rule.JavaDialectRuntimeData$PackageClassLoader/org.drools.rule.JavaDialectRuntimeData/org.drools.rule.MVELDialectRuntimeDataobjects are occupying the large part.
Resolution
- There are 2 workarounds for this issue:
-
Update the timestamp of all files under the directory which
changesetlooks at soKnowledgeAgentImpl.registeredResourceswill be fully updated. This can be done bytouch *.drlunder the directory in Linux. This operation should be automated periodically (e.g. once per hour) or every time you update aDRLfile. -
Use
newInstance=falseforKnowledgeAgent:kagentConf.setProperty( "drools.agent.newInstance", "false" ); knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent("ReceiverConfigurationKAgent", kagentConf);
-
Root Cause
- This content is not included.Bug 1067841 - Compiled resource objects leak in KnowledgeAgentImpl.registeredResources
- Conditions for this bug:
ChangeSetwhich points at a directory forDRLfiles- Those
DRLfiles have rules for the same package newInstance=true
KnowledgeAgentImpl.registeredResourceshas entries for eachDRLfiles under the directory and holdsorg.drools.rule.Ruleobjects which lead to compiled resource objects likeorg.mvel2.compiler.CompiledExpression,org.drools.rule.DialectRuntimeRegistry, etc.- When one
DRLfile in the directory is updated, the package andkbaseis fully updated and the entry inKnowledgeAgentImpl.registeredResourcesis updated as well. But other entries still retain oldorg.drools.rule.Ruleobjects hence related compiled resource objects will not be garbage collected. - Condition 1 is not mandatory. This issue can happen when
KnowledgeAgentis looking at multiple resources for the same package.
Diagnostic Steps
- Capture a heap dump. If multiple
org.drools.rule.DialectRuntimeRegistry/org.drools.rule.JavaDialectRuntimeData$PackageClassLoader/org.drools.rule.JavaDialectRuntimeData/org.drools.rule.MVELDialectRuntimeDataobjects are occupying the heap, it would hit this KCS solution. - Use Eclipse Memory Analyzer Tool feature 'path to GC' to reach the root object. It should be
KnowledgeAgentImpl.registeredResources.
Product(s)
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.