<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2>Hi Ron,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2>yes I do create a new working memory each time. In the 
middle of testing the change, I'll let you know the outcome.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=225445404-24042007><FONT face=Arial 
color=#0000ff size=2>Matt.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Ronald R. 
DiFrango<BR><B>Sent:</B> Tuesday, 24 April 2007 4:25 AM<BR><B>To:</B> Rules 
Users List<BR><B>Subject:</B> Re: [rules-users] Potential memory 
problems<BR></FONT><BR></DIV>
<DIV></DIV>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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
  <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 face="Courier New" color=#7f0055 size=2>try</FONT></B><FONT 
  face="Courier New" color=#000000 size=2> {</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>handle = wm.assertObject(shift);</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>wm.assertObject(shiftCalculator);</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>wm.fireAllRules();</FONT> <BR><FONT face="Courier New" 
  color=#000000 size=2>}</FONT><B> <FONT face="Courier New" color=#7f0055 
  size=2>catch</FONT></B><FONT face="Courier New" color=#000000 size=2> 
  (RuntimeDroolsException e) {</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B> <FONT face="Courier New" 
  color=#7f0055 size=2>throw</FONT></B><FONT face="Courier New" color=#000000 
  size=2></FONT><B> <FONT face="Courier New" color=#7f0055 
  size=2>new</FONT></B><FONT face="Courier New" color=#000000 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 face="Courier New" 
  color=#2a00ff size=2>"Could not add shift to Working Memory"</FONT><FONT 
  face="Courier New" color=#000000 size=2>, e);</FONT> <BR><FONT 
  face="Courier New" color=#000000 size=2>}</FONT> <BR><FONT face="Courier New" 
  color=#000000 size=2>wm.clearAgenda();</FONT> <BR><FONT face="Courier New" 
  color=#000000 size=2>wm.dispose();</FONT> <BR><FONT face="Courier New" 
  color=#000000 size=2>LoggingUtils.<I>logMethodFinish</I>(</FONT><I><FONT 
  face="Courier New" color=#0000c0 size=2>logger</FONT></I><FONT 
  face="Courier New" color=#000000 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 face="Courier New" color=#7f0055 size=2>finally</FONT></B><FONT 
  face="Courier New" color=#000000 size=2> {</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>wm.clearAgenda();</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>wm.dispose();</FONT> 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT face="Courier New" 
  color=#000000 size=2>LoggingUtils.</FONT><I><FONT face="Courier New" 
  color=#000000 size=2>logMethodFinish</FONT></I><FONT face="Courier New" 
  color=#000000 size=2>(</FONT><I> <FONT face="Courier New" color=#0000c0 
  size=2>logger</FONT></I><FONT face="Courier New" color=#000000 size=2>, 
  methodName);</FONT> <BR><FONT face="Courier New" color=#000000 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></BODY></HTML>

<table><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></table>