Hello,<br>
<br>
Recently I've been using Drools (version 5.0.1) to build a small sensor
monitoring application and have run into memory consumption issues that
seem to be related to logically inserted facts. The way it is set up
there are Sensor facts which carry numerically encoded "flags" that can
signal certain properties about that Sensor. My intent was to create
rules to detect these flags and insert marker facts in order to abstract
how flagging is handled and make it easier for other rules to use this
information. Here is an example of the rules I'm using:<br>
<br>
<br>
<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">declare
DeltaFlagged<br>
sensor : Sensor @key<br>
end </blockquote>
<div> </div>
<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">rule "Delta
Flagged"<br>
agenda-group "delta flag inference"<br>
auto-focus true<br>
when<br>
$sensor: Sensor(eval(isDeltaFlag(flag)))<br>
then<br>
DeltaFlagged flagged = new DeltaFlagged();<br>
flagged.setSensor($sensor);<br>
insertLogical(flagged);<br>
end<br>
</blockquote>
<br>
Each Sensor is updated at regular intervals from outside of the rule
engine, several hundred times a day. Similar to the examples given here
(
<a href="http://blog.athico.com/2007/03/writing-rules-for-monitoring-and-time.html" target="_blank">http://blog.athico.com/2007/03/writing-rules-for-monitoring-and-time.html</a>
). This works very well for short periods of time. However, after
many days of operation I can observe a clear memory leak trend. When I
inspect a memory dump I see that there are many LogicalDependency
objects created and stored by the truth maintenance system (on the order
of several million) for each "flag" fact that has been logically
inserted. Only one fact is being inserted per Sensor as expected. I am
working under the impression that Drool's truth maintenance should not
be recording duplicate dependencies, so I'm wondering what I have done
wrong with the equals() and hashcode() methods of my objects to cause
Drools to treat each activation of this rule as a new dependency. My
Sensor objects use the default hashcode and equals methods. Thank you
in advance.<br>
<br>Bill