Matt,<br><br>I am sure that would work, but I wonder are you building a new working memory each time as well?&nbsp; If not then maybe you should.&nbsp; My methods always look something like the following:<br><br>{<br>&nbsp;&nbsp;&nbsp; final WorkingMemory workingMemory = 
ruleBase.newWorkingMemory();<br>&nbsp;&nbsp;&nbsp; // Assert my objects<br>&nbsp;&nbsp;&nbsp; workingMemory.assertObject(object);<br>&nbsp;&nbsp;&nbsp; // Fire the rules<br>&nbsp;&nbsp;&nbsp; workingMemory.fireAllRules();<br>&nbsp;&nbsp;&nbsp; // Return what ever you need to<br>&nbsp;&nbsp;&nbsp; return result;
<br>}<br><br>That way WorkingMemory is thrown away each time.&nbsp; Also, it is fairly low overhead to create one each time.&nbsp; Especially given that you clear and dispose each.<br><br>Ron<br><br><div><span class="gmail_quote">On 4/23/07, 
<b class="gmail_sendername">Matthew Shaw</b> &lt;<a href="mailto:mshaw@emergency.qld.gov.au">mshaw@emergency.qld.gov.au</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">







<div>


<p><font face="Arial" size="2">Hi,</font>
</p>

<p><font face="Arial" size="2">I am fronting my rule engine by a stateless session façade bean, running in a weblogic container. The rule bases are loaded only once via a singleton. </font></p>

<p><font face="Arial" size="2">I was running a profiler over the app and have noticed a lot of rule engine objects still attached to the tree. My stub which invokes the working memory looks like the following: </font></p>


<p><b><font color="#7f0055" face="Courier New" size="2">try</font></b><font color="#000000" face="Courier New" size="2"> {</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">handle = wm.assertObject(shift);</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">wm.assertObject(shiftCalculator);</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">wm.fireAllRules();</font>

<br><font color="#000000" face="Courier New" size="2">}</font><b> <font color="#7f0055" face="Courier New" size="2">catch</font></b><font color="#000000" face="Courier New" size="2"> (RuntimeDroolsException e) {</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> <font color="#7f0055" face="Courier New" size="2">throw</font></b><font color="#000000" face="Courier New" size="2"></font><b> <font color="#7f0055" face="Courier New" size="2">new</font></b><font color="#000000" face="Courier New" size="2">
 TimesheetServiceUnavailableException(</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#2a00ff" face="Courier New" size="2">&quot;Could not add shift to Working Memory&quot;</font><font color="#000000" face="Courier New" size="2">, e);</font>

<br><font color="#000000" face="Courier New" size="2">}</font>

<br><font color="#000000" face="Courier New" size="2">wm.clearAgenda();</font>

<br><font color="#000000" face="Courier New" size="2">wm.dispose();</font>

<br><font color="#000000" face="Courier New" size="2">LoggingUtils.<i>logMethodFinish</i>(</font><i><font color="#0000c0" face="Courier New" size="2">logger</font></i><font color="#000000" face="Courier New" size="2">, methodName);
</font>
</p>

<p><font face="Arial" size="2">As you can see if an exception occurs then the dispose method is not run. Could this lead to memory leakage?</font>
</p>

<p><font face="Arial" size="2">I have subsequently modified the offending stub to include a finally block</font>
</p>

<p><b><font color="#7f0055" face="Courier New" size="2">finally</font></b><font color="#000000" face="Courier New" size="2"> {</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">wm.clearAgenda();</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">wm.dispose();</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000000" face="Courier New" size="2">LoggingUtils.</font><i><font color="#000000" face="Courier New" size="2">logMethodFinish</font></i><font color="#000000" face="Courier New" size="2">(</font><i>
<font color="#0000c0" face="Courier New" size="2">logger</font></i><font color="#000000" face="Courier New" size="2">, methodName);</font>

<br><font color="#000000" face="Courier New" size="2">}</font>
</p>

<p><font face="Arial" size="2">Matt Shaw</font>

<br><font face="Arial" size="2">Snr Applications Developer</font>

<br><font face="Arial" size="2">Service Performance &amp; Management Unit</font>

<br><font face="Arial" size="2">Phone: 3247 8666. ext. 94666</font>
</p>

</div>

<table><tbody><tr><td bgcolor="#ffffff"><font color="#000000">This correspondence is for the named persons only. <br>
It may contain confidential or privileged information or both. <br>
No confidentiality or privilege is waived or lost by any mis transmission. <br>
If you receive this correspondence in error please delete it from your system immediately and notify the sender. <br>
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. <br>
Any opinions expressed in this message are those of the individual sender except where the sender expressly, <br>
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.<br>
</font></td></tr></tbody></table><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" 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>