[rules-users] Performance and Memory Utilization - StatefulKnowledgeSession
Edson Tirelli
ed.tirelli at gmail.com
Thu Feb 4 13:02:33 EST 2010
You are leaking memory there, because you are not calling the dispose in
the first session, if you run the second.
[]s
Edson
2010/2/4 HonorGod <jagadeesh.motamarri at barclayscapital.com>
>
> I have over million rows of data that are stored in a fact model. I have to
> apply 2 sets of rules [coming from 2 decision tables - cannot combine them
> for a specific reason] on each fact model.
>
> I have created static knowledgebases and stored them in cache so that they
> can be used when ever new StatefulKnowledgeSessions are required.
>
> This is how I am doing it -
>
> Iterating over the fact model one after the other and pass them to the
> method that applies rules -
>
> public int applyRules(MyModel model) {
> int noOfRulesFired = 0 ;
> StatefulKnowledgeSession kSession =
>
> ((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("FirstSetOfRules")).newStatefulKnowledgeSession()
> ;
> kSession.insert(model);
> noOfRulesFired = kSession.fireAllRules();
>
> if( noOfRulesFired >= 1 ) {
> kSession =
>
> ((KnowledgeBase)DroolsKnowledgeBaseManager.getInstance().knowledgeBases.get("SecondSetOfRules")).newStatefulKnowledgeSession()
> ;
>
> kSession.insert(model);
> kSession.insert(this);
> noOfRulesFired +=kSession.fireAllRules();
> }
> kSession.dispose() ;
> return noOfRulesFired ;
> }
>
> Is this good approach? How can I reuse StatefulKnowledgeSessions so that I
> can insert my fact models one at a time and fire rules. Creating new
> StatefulKnowledgeSession for every fact model is consuming lot of memory
> and
> even though dispose() is called before existing method - GC might not clean
> it instently.
>
> Please assist [I am in middle of UAT and started to notice that memory
> consumption is too high] .
>
> Thanks
> --
> View this message in context:
> http://n3.nabble.com/Performance-and-Memory-Utilization-StatefulKnowledgeSession-tp187463p187463.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100204/1bdd1c52/attachment.html
More information about the rules-users
mailing list