<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Quinn, Dan wrote:
<blockquote
 cite="mid:1E5E8FAA97B3F149BACC39DAA9E63DF3085E2934@EXCHVS01.mail.blue.fedex.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta content="MSHTML 6.00.6000.16825" name="GENERATOR">
  <div dir="ltr" align="left"><span class="296013715-29042009"><font
 color="#0000ff" face="Arial" size="2">We are writing an app which has
a large number of facts. This app&nbsp;also needs to make lots&nbsp;of queries
against working memory. Our memory footprint seems to be expanding at
an undesirable rate due to the number of queries made against working
memory.&nbsp;It is increasing at a rate where after a couple of days the app
will consume all&nbsp;the resources on the machine. This app&nbsp;is stateful and
needs to stay up for a long duration. Rebooting it&nbsp;every couple of day
to clean up working memory&nbsp;would not be acceptable.</font></span></div>
  <div dir="ltr" align="left"><span class="296013715-29042009"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="296013715-29042009"><font
 color="#0000ff" face="Arial" size="2">&nbsp;It seems to me that the queries
are being added to working memory as facts, but the query is not
retracted after its result is returned. Is that true? Is there
something I need to do so query facts are removed after the results are
returned to keep the size of working memory down?</font></span></div>
</blockquote>
I just ran MiscTest.testQuery, executing it 10K times to see if there
is a memory leak. On this example I couldn't find anything. DroolsQuery
objects are inserted, but left memory is turned off for querries, so it
shouldn't be remembered - the facthandle just needs destroying at the
end. Could you provide a similar example to MiscTest.testQuery that
demonstrates that memory leak. <br>
<br>
We just fixed the Eclipse regression, so ready to release 5.0 now,&nbsp; so
if you want this fixed for then, you'll need to be quick :)<br>
<br>
Thanks<br>
<br>
Mark<br>
<blockquote
 cite="mid:1E5E8FAA97B3F149BACC39DAA9E63DF3085E2934@EXCHVS01.mail.blue.fedex.com"
 type="cite">
  <div dir="ltr" align="left"><span class="296013715-29042009"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="296013715-29042009"><font
 color="#0000ff" face="Arial" size="2">Has this behavior changed since
Drools 4.0.7. I don't recall seeing this issue running against the
older version of Drools.</font></span></div>
  <div dir="ltr" align="left"><span class="296013715-29042009"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="296013715-29042009"><font
 color="#0000ff" face="Arial" size="2">Thanks,</font></span></div>
  <div dir="ltr" align="left"><span class="296013715-29042009"><font
 color="#0000ff" face="Arial" size="2">Dan</font></span></div>
  <div>&nbsp;</div>
  <div align="left"><font face="Arial" size="2">Daniel Quinn</font></div>
  <div align="left"><font face="Arial" size="2">Fedex - Custom Critical</font></div>
  <div align="left"><font face="Arial" size="2">Software Specialist I</font></div>
  <div align="left"><font face="Arial" size="2">234.310.4090(x2586)</font></div>
  <div>&nbsp;</div>
  <br>
  <div class="OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
  <hr tabindex="-1"><font face="Tahoma" size="2"><b>From:</b>
<a class="moz-txt-link-abbreviated" href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
[<a class="moz-txt-link-freetext" href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>David
Sinclair<br>
  <b>Sent:</b> Friday, April 03, 2009 3:20 PM<br>
  <b>To:</b> Rules Users List<br>
  <b>Subject:</b> Re: [rules-users] Locating facts via slot values<br>
  </font><br>
  </div>
Here you go WolfGang<br>
  <br>
rule shoot-3 <br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $h : Hunter( $target : target)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Animal(this == $target)<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $h.shoot( $a );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retract( $a );<br>
end<br>
  <br>
  <div class="gmail_quote">2009/4/3 Wolfgang Laun <span dir="ltr">&lt;<a
 moz-do-not-send="true" href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.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;">Given
a working memory containing a large number of rather static facts which
are from several subclasses (Ape, Bear, Crocodile,...) of some base
class (Animal) and a single fact of class Hunter with a field target of
type Animal, the shooting of an animal might be written with a rule
like this:<br>
    <br>
rule shoot-1<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h : Hunter( ?target : target )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?a : Animal()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eval(?target == ?a)<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h.shoot( ?a );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retract( ?a );<br>
end<br>
    <br>
Avoiding eval (which is said to be inefficient), it could also be
written as<br>
    <br>
rule shoot-2<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?a: Animal()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h : Hunter( target&nbsp; == ?a )<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h.shoot( ?a );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retract( ?a );<br>
end<br>
    <br>
This, however, places the pattern with many instances up front, which
is (AFAIK) not so good in a Rete implementation.<br>
    <br>
Which one is to be preferred in Drools?<br>
    <br>
Ideally, one might want to write <br>
    <br>
rule shoot-3<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h : Hunter( ?target : target )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?a == ?target : Animal()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ### not valid DRL<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?h.shoot( ?a );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; retract( ?a );<br>
end<br>
    <br>
This avoids eval, has the single instance fact up front, but it isn't
available.<br>
    <font color="#888888"><br>
-W<br>
    <br>
    <br>
    <br>
    </font><br>
_______________________________________________<br>
rules-users mailing list<br>
    <a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
    <a moz-do-not-send="true"
 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>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>