Hi, thank you for your response.<div><br></div><div>We use Drools 5.3.1 through Maven. When I invoke Drools, for each event I receive I do the following:</div><div><br></div><div><div><font face="courier new, monospace"> ksession.insert(obj);</font></div>
<div><font face="courier new, monospace"> ksession.fireAllRules();</font></div><div><br></div><div>where ksession was previously created through</div><div><br></div><div><div><font face="courier new, monospace"> kbase = KnowledgeBaseFactory.newKnowledgeBase();</font></div>
<div><font face="courier new, monospace"> kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());</font></div><div><font face="courier new, monospace"> ksession = kbase.newStatefulKnowledgeSession();</font></div></div>
<div><br></div><div>Yes, we do use timers. In one case we want to remove alarms that have been cleared for more than an hour from the knowledgebase. We don't remove them immediately because some alarms clear briefly and then come back. The rule I've written to handle this situation is the following:</div>
<div><br></div><div><div><font face="courier new, monospace">rule "Old Cleared Alarm?"</font></div><div><font face="courier new, monospace">timer(int: 10m 10m)</font></div><div><font face="courier new, monospace">salience -10</font></div>
<div><font face="courier new, monospace">when</font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>$a : Alarm(severity == "cleared")</font></div><div>
<font face="courier new, monospace">then</font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span></font><span style="font-family:'courier new',monospace">double lastUpdate = minutesSince($a.getEventTime());</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font face="courier new, monospace">        </font></span><span style="font-family:'courier new',monospace">if(lastUpdate > 60) { </span><span class="Apple-tab-span" style="font-family:'courier new',monospace;white-space:pre">        </span></div>
<div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>logger.debug("Alarm " + $a.getAlarmId() + " is old. Removing...");</font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>retract($a);</font></div>
<div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><font face="courier new, monospace">end</font></div></div><div><br></div><div>Is there any other way to write this? I've found that I can't put the <span style="font-family:'courier new',monospace">minutesSince($a.getEventTime())</span> in the rule's when-clause.</div>
<div><br></div><div>Thank you,</div><div>Werner</div><br><div class="gmail_quote">On Tue, May 29, 2012 at 8:10 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just to make sure: How do you invoke the Engine? (I suppose you don't<br>
call with a limit for rule firings.)<br>
<br>
Unless it's a bug (BTW: your Drools version is?), it's due to one or<br>
more of your rules.<br>
<br>
Are you using timers? How?<br>
<br>
A detailed investigation of the whereabouts of these<br>
ScheduledAgendaItem objects might be done by investigating (via the<br>
unstable API) the Agenda and its various components.<br>
<br>
-W<br>
<div><div class="h5"><br>
On 28/05/2012, Werner Stoop <<a href="mailto:wstoop@gmail.com">wstoop@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> We're using Drools with a StatefulKnowledgeSession to process events coming<br>
> from equipment in our network. The system draws conclusions about the state<br>
> of the equipment and writes those conclusions to a table in our<br>
> database. All our rules work as we expected and the system produces the<br>
> correct results.<br>
><br>
> However, the memory usage of the JVM steadily goes up when the system runs<br>
> for extended periods of time until we start getting OutOfMemoryExceptions<br>
> and the server has to be restarted. This is in spite of the fact that the<br>
> fact count reported by<br>
> the StatefulKnowledgeSession.getFactCount() stays reasonably stable,<br>
> with around 30 000 facts (give or take) at any point in time.<br>
><br>
> I have run the Eclipse Memory Analyzer tool (<a href="http://www.eclipse.org/mat/" target="_blank">http://www.eclipse.org/mat/</a>)<br>
> against heap dumps from the JVM several times now, and every time it<br>
> reports more and more instances<br>
> of org.drools.common.ScheduledAgendaItem referenced from one instance of<br>
> java.lang.Object[]<br>
><br>
> To be concrete, since this morning the uptime is more than 112 hours in<br>
> total, during which the system has processed little over 2 000 000 events<br>
> from the network. It has 29 000 facts in the knowledge session, yet in the<br>
> heap dump we see 829 632 instances of<br>
> org.drools.common.ScheduledAgendaItem.<br>
><br>
> What is the ScheduledAgendaItem for? Is there something wrong with my rules<br>
> that causes this many instances to be held? Is there something I should do<br>
> to release these instances or the Object[] holding on to them?<br>
><br>
> Thanks,<br>
> Werner Stoop<br>
><br>
</div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>