Hi,<br><br>I've recently started using some of the temporal operators
that drools supports (coincides, starts, finishes, during) and have had
trouble with events not being expired, causing severe memory
consumption.<br>
I'd first like to make sure that I'm using these operators appropriately, so as a test case I have rules like:<br><br>declare A<br> @role( event )<br> @timestamp( timestamp )<br> @duration( duration )<br>end<br>
<br>declare B<br> @role( event )<br> @timestamp( timestamp )<br> @duration( duration )<br>end<br><br>rule "coincides events"<br>when<br> $a: A() from entry-point "a"<br> $b: B(this coincides $a) from entry-point "b"<br>
then insert("coincides"); end<br><br>With classes like:<br><br>public class A{<br> public final long timestamp;<br> public final long duration;<br> public A(long timestamp, long duration){<br>
this.timestamp = timestamp;<br> this.duration = duration;<br> }<br>}<br><br>//B is identical to A.<br><br>Using a knowledge base configured with stream mode, and a knowledge session with a pseudo clock I'd run this test:<br>
<br>A a = new A(0, 1000);<br>B b = new B(0, 1000);<br> <br>entryPointA.insert(a);<br>entryPointB.insert(b);<br>clock.advanceTime(1000, TimeUnit.MILLISECONDS);<br>ksession.fireAllRules();<br><br>In
this test I'm expecting that the rule will fire to insert "coincides"
and expire both A and B. But instead, "coincides" is inserted, B is
expired, but A remains in memory permanently. If I use jvisualvm to
inspect the expirationOffset for A, I see that it is the Long.MAX value
of 9223372036854775807. This behavior persists even after adding an
explicit expiration to A. I was under the impression that the offset
would be zero (of close to it) since Drools would only need to retain A
until the clock reaches A's endTimestamp. The documentation does not
cover the calculation of event expiration in great detail, so have I
missed something? Thanks in advance.