High memory issue with RuleTerminalNodeLeftTuple objects occupying most of heap space in Drools 6
Issue
- User faces memory issues while firing rules with 1000 facts (e.g. of type
Cheese
) inRed Hat JBoss BRMS 6.x
. Take an example of the following rule.
rule "CheeseFilter"
when
$cheese1:Cheese(type == "Soft")
$cheese2:Cheese(type == "Unprocessed")
eval(compareCheese($cheese1,$cheese2)
then
end
The problem is that it has been observed in some scenarios, when there are more than 1000 number of facts inserted into WorkingMemory
, the number of EvalNodeLeftTuple
is huge, even though the rules were already fired. Here is how the Heap space histogram looks like after rule was fired.
num #instances #bytes class name
----------------------------------------------
1: 56636683 6330108496 org.drools.core.reteoo.EvalNodeLeftTuple
2: 1987952 191283392 org.drools.core.reteoo.FromNodeLeftTuple
3: 1819342 92748416 java.util.HashMap
4: 2748121 85519872 java.util.HashMap$Node
...
Since the use of eval()
method is discouraged due to similar issues, the same rule has been updated to check if that makes any difference.
rule "CheeseFilterNoEval"
when
$cheese1:Cheese(type == "Soft")
$cheese2:Cheese(type == "Unprocessed",compareCheese($cheese1,$cheese2))
then
end
However this time the Heap memory histogram was now showing majority of objects occupying the space was of RuleTerminalNodeLeftTuple
. To be precise, now the EvalNodeLeftTuple
has now been replaced by RuleTerminalNodeLeftTuple
and the memory size was increased.
num #instances #bytes class name
----------------------------------------------
1: 51540200 7776910400 org.drools.core.reteoo.RuleTerminalNodeLeftTuple
2: 2130648 184982208 org.drools.core.reteoo.FromNodeLeftTuple
3: 1814433 92512784 java.util.HashMap
4: 2889611 89847552 java.util.HashMap$Node
...
- What purpose has
RuleTerminalNodeLeftTuple
? - Why is it seen with so many instances occupying so much of Heap memory , occespecially when the rule has been fired already?
- How to reduce the memory size occupied by the
RuleTerminalNodeLeftTuple
instances?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.