<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff 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><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff 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>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff 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><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff size=2>Thanks,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296013715-29042009><FONT face=Arial 
color=#0000ff 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 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>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>
<DIV></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 
href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">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 
  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></BODY></HTML>