[rules-users] Frequently updated facts and truth maintenance

bill simms sitrious at gmail.com
Thu May 6 13:59:29 EDT 2010


Hello,

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:


declare DeltaFlagged
>     sensor : Sensor @key
> end



> rule "Delta Flagged"
> agenda-group "delta flag inference"
> auto-focus true
>     when
>         $sensor:    Sensor(eval(isDeltaFlag(flag)))
>     then
>         DeltaFlagged flagged = new DeltaFlagged();
>         flagged.setSensor($sensor);
>         insertLogical(flagged);
> end
>

Each Sensor is updated at regular intervals from outside of the rule engine,
several hundred times a day.  Similar to the examples given here (
http://blog.athico.com/2007/03/writing-rules-for-monitoring-and-time.html).
 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.

Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100506/9bca45ec/attachment.html 


More information about the rules-users mailing list