<br> You are leaking memory there, because you are not calling the dispose in the first session, if you run the second.<br><br> []s<br> Edson<br><br><div class="gmail_quote">2010/2/4 HonorGod <span dir="ltr"><<a href="mailto:jagadeesh.motamarri@barclayscapital.com">jagadeesh.motamarri@barclayscapital.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I have over million rows of data that are stored in a fact model. I have to<br>
apply 2 sets of rules [coming from 2 decision tables - cannot combine them<br>
for a specific reason] on each fact model.<br>
<br>
I have created static knowledgebases and stored them in cache so that they<br>
can be used when ever new StatefulKnowledgeSessions are required.<br>
<br>
This is how I am doing it -<br>
<br>
Iterating over the fact model one after the other and pass them to the<br>
method that applies rules -<br>
<br>
public int applyRules(MyModel model) {<br>
int noOfRulesFired = 0 ;<br>
StatefulKnowledgeSession kSession =<br>
((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("FirstSetOfRules")).newStatefulKnowledgeSession()<br>
;<br>
kSession.insert(model);<br>
noOfRulesFired = kSession.fireAllRules();<br>
<br>
if( noOfRulesFired >= 1 ) {<br>
kSession =<br>
((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("SecondSetOfRules")).newStatefulKnowledgeSession()<br>
;<br>
<br>
kSession.insert(model);<br>
kSession.insert(this);<br>
noOfRulesFired +=kSession.fireAllRules();<br>
}<br>
kSession.dispose() ;<br>
return noOfRulesFired ;<br>
}<br>
<br>
Is this good approach? How can I reuse StatefulKnowledgeSessions so that I<br>
can insert my fact models one at a time and fire rules. Creating new<br>
StatefulKnowledgeSession for every fact model is consuming lot of memory and<br>
even though dispose() is called before existing method - GC might not clean<br>
it instently.<br>
<br>
Please assist [I am in middle of UAT and started to notice that memory<br>
consumption is too high] .<br>
<br>
Thanks<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n3.nabble.com/Performance-and-Memory-Utilization-StatefulKnowledgeSession-tp187463p187463.html" target="_blank">http://n3.nabble.com/Performance-and-Memory-Utilization-StatefulKnowledgeSession-tp187463p187463.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<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>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>