This is strange - do you mean that those 18 KnowledgeAgents stored in that Map produce 18 different StatefulKnowledgeSessions?<br><br>What does the Map&lt;X,Y&gt; map? X? Y?<br><br>-W<br><br><div class="gmail_quote">2011/7/13 Jeffrey Schneller <span dir="ltr">&lt;<a href="mailto:jeffrey.schneller@envisa.com">jeffrey.schneller@envisa.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal">I am currently running version 5.1.0M2.  I have 18 different binary rulesets [packages] that are stored on the local filesystem.  The rulesets range in size from 4K to 131Mb. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">When my application starts I load each ruleset into a knowledgeAgent and store the knowledgeAgent into a hashmap which is stored in memory.   They are loaded using the following xml:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;<u></u><u></u></p><p class="MsoNormal">&lt;change-set xmlns=&#39;<a href="http://drools.org/drools-5.0/change-set" target="_blank">http://drools.org/drools-5.0/change-set</a>&#39; xmlns:xs=&#39;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#39; xs:schemaLocation=&#39;<a href="http://drools.org/drools-5.0/change-set.xsd" target="_blank">http://drools.org/drools-5.0/change-set.xsd</a>&#39;&gt;<u></u><u></u></p>
<p class="MsoNormal" style="text-indent: 0.5in;">&lt;add&gt;<u></u><u></u></p><p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;">&lt;resource source=&#39;file://PATH_TO_BINARY&#39; type=&#39;PKG&#39; /&gt;<u></u><u></u></p>
<p class="MsoNormal" style="text-indent: 0.5in;">&lt;/add&gt;<u></u><u></u></p><p class="MsoNormal">&lt;/change-set&gt;<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The knowledgeAgentConfiguration is setup as:<u></u><u></u></p>
<p class="MsoNormal" style="text-indent: 0.5in;">drools.agent.scanDirectories = false<u></u><u></u></p><p class="MsoNormal" style="text-indent: 0.5in;">drools.agent.newInstance = false<u></u><u></u></p><p class="MsoNormal" style="text-indent: 0.5in;">
drools.agent.scanResources = false<u></u><u></u></p><p class="MsoNormal" style="text-indent: 0.5in;">drools.agent.monitorChangeEvents = false<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">After the all the agents are loaded and stored in the hashmap the total memory used in the app is 6.2GB.  <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Once the application is running, if a business user needs to update a set of rules there is a process in place to refresh all the knowledgeAgents with new rulesets.  In a new thread. the code clears the hashmap, sets the hashmap to null, calls for garbage collection to occur, and it then constructs a new hashmap and loads all the rules as it does at application startup. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The knowledge agent is logging the following when the ruleset is loaded:<u></u><u></u></p><p class="MsoNormal" style="text-indent: 0.5in;">KnowledgeAgent applying ChangeSet<u></u><u></u></p>
<p class="MsoNormal" style="text-indent: 0.5in;">KnowledgeAgent performing an incremental build of the ChangeSet<u></u><u></u></p><p class="MsoNormal" style="text-indent: 0.5in;">KnowledgeAgent incremental build of KnowledgeBase finished and in use<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">It takes a large amount of time to do this process [double to triple the time of application startup]. After this occurs the memory used by the app increases [to nearly double the original size 12.2GB] and the CPU is maxed out.  After some time the CPU usage drops and the app is usable again but the memory never decreases.  If a business user refreshes the rules again, the memory increases again and the CPU is maxed out and the app becomes unresponsive because the memory is completely maxed out.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">There is obviously a memory leak somewhere and a large one at that.  Is this the proper way to be caching KnowledgeAgents into memory so the rulessets don’t need to be re-loaded everytime a knowledgeAgent is run?  Is my problem the use of the hashmap?  Do I need to remove the original knowledgeAgents that were in the hashmap?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks for any help.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div><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>
<br></blockquote></div><br>