<font size="2"><font face="verdana,sans-serif">Hi there,</font></font><div><font size="2"><font face="verdana,sans-serif"><br></font></font></div><div><font size="2"><font face="verdana,sans-serif">First of all, thank you for your detailed and quick response. Next...<br>
</font></font><br><div class="gmail_quote">2010/3/31 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>    Miguel,<br><br>    First we need to understand where is this memory spent. Drools externalizes the actual rule compilation to a java compiler (JDT or Janino) and I would not be surprised if compiling 2100 rules would consume more than 300Mb **during compilation**. I don&#39;t think that after compiling, the application will continue to use that amount of memory just because of rules, although if you have many facts being inserted into your session, it obviously will drive consumption up.<br>
</blockquote><div><br></div><div>I usually load into memory 2~4 facts each time, very small objects. I then &quot;fire all rules&quot; and immediately retract and dispose.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>    So, some questions:<br><br>1. Do you use one KnowledgeBuilder to compile all your rule files or do you use one KnowledgeBuilder per file?<br></blockquote><div><br></div><div>Just one, declared as a static variable.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">2. How much memory is your application using during this step, where you add resources to your knowledgeBuilder(s)?<br>
</blockquote><div><br></div><div>Its taking about ±20 MB just before it reads the DRL file, it then takes 5~10s for loading rules into memory and immediately after that line its taking +300MB.. kinda stabilizes afterwards.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
3. After compiling your knowledge packages, did you tried to force a GC to check how much memory it continues to use?<br></blockquote><div><br></div><div>Just tested that, it barely makes a difference :-/ (less than 5MB saved)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">4. Are you adding all rules to the same KnowledgeBase or using one kbase per set of rules? How much memory are you consuming in this step?<br>
</blockquote><div><br></div><div>Most of the time, i&#39;ve been testing with only one rule file with +2100 rules and for that i create a single knowledge base, from which i create the ksession. However, the whole system i&#39;m developing has another component of event analysis so eventually i&#39;ll be testing two separate threads doing similar things but on different DRL files. I suppose i&#39;ll be using two kbase&#39;s, one for each file...</div>
<div><br></div><div>This is the step where memory usage increases dramatically:</div><div><br></div><div> <span class="Apple-style-span" style="font-family: &#39;Palatino Linotype&#39;, &#39;Book Antiqua&#39;, Palatino, FreeSerif, serif; font-size: 13px; color: rgb(51, 51, 51); line-height: 19px; "><a id="d0e1849"><div class="example-contents" style="display: inline !important; ">
<pre class="programlisting" style="font-size: 0.9em; font-family: courier, serif; display: inline !important; background-color: rgb(245, 245, 245); color: rgb(51, 51, 51); overflow-x: auto; overflow-y: auto; padding-top: 5px; padding-right: 15px; padding-bottom: 5px; padding-left: 25px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); ">
kbuilder.add( ResourceFactory.newFileSystemResource( fileName ), ResourceType.DRL );</pre></div></a></span></div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

5. Did you tried compiling it once, generating the kbase and serializing it to a file, and then, instead of recompiling everything, just deserialize the file into memory and using it? How much memory it consumes when you deserialize from a file?<br>
</blockquote><div><br></div><div>Not sure what you mean there, is it this: <a href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e1070">http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e1070</a> ? if so, yes, i&#39;ve tried it and noticed no difference at all, was i supposed to?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>   Knowing the answer to the above questions will help to determine if you have a problem and how to work around it or fix it.<br></blockquote><div><br></div><div>thanks for your help so far. Any help is very much appreciated.</div>
<div><br></div><div>_ miguel</div><div><br></div></div><br>-- <br>&quot;To understand what is recursion you must first understand recursion&quot;<br>
</div>