<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Thanks for reporting, we'll investigate
both this and 498<br>
Davide<br>
<br>
On 07/11/2014 08:38 PM, Kent Anderson wrote:<br>
</div>
<blockquote
cite="mid:749AF81F-EB48-458A-8457-735CA44DD7D6@psware.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div>We have found a workaround that eliminates the leftover event
(gone from Working Memory, but not from the JVM memory): </div>
<div><br>
</div>
<div>The rule “forget it ever happened” (seen below) causes the
problem. Re-writing it to remove the check for RAISE in the LHS
eliminated the memory leak. Of course, our application requires
the check for RAISE, so it can be accomplished by manually
querying working memory from the RHS. It’s ugly, but it
resolved the issue.</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
style="color: #a91500">query</span> existsRaise($id)</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>$raise
: MyEvent( eventState == EventState.RAISE, eventId == $id )</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(169, 21, 0);">end</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
min-height: 15px;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(0, 143, 0);"><span style="color: #a91500">rule</span><span
style="color: #000000"> </span>"process clear"</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(169, 21, 0);"><span style="color: #000000"><span
class="Apple-tab-span" style="white-space:pre"> </span></span>no-loop</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(169, 21, 0);">when</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>$clear
: MyEvent(eventState == EventState.CLEAR, $clearId : eventId)</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(169, 21, 0);">then</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>QueryResults
results = kcontext.getKieRuntime().getQueryResults( <span
style="color: #008f00">"existsRaise"</span>, $clearId );</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span><span
style="color: #a91500">if</span> (results.size() == 0) { </div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>System.out.println(
<span style="color: #008f00">"Forwarding CLEAR("</span> +
$clearId + <span style="color: #008f00">")"</span> ); </div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>} <span
style="color: #a91500">else</span> {</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;">
<span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println(<span
style="color: #008f00">"Forgetting RAISE/CLEAR("</span> +
$clearId + <span style="color: #008f00">")"</span>);</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>
<span style="color: #a91500">for</span> (QueryResultsRow
row : results){</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;">
<span class="Apple-tab-span" style="white-space:pre"> </span><span
class="Apple-tab-span" style="white-space:pre"> </span>MyEvent
raise = (MyEvent) row.get (<span style="color: #008f00">"$raise"</span>);</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;">
<span class="Apple-tab-span" style="white-space:pre"> </span>delete(raise);</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre"> </span>delete($clear);</div>
<div style="margin: 0px; font-size: 11px; font-family: Monaco;
color: rgb(169, 21, 0);">end</div>
</div>
<div><br>
</div>
<div>This appears to be a similar situation to <a
moz-do-not-send="true"
href="https://issues.jboss.org/browse/DROOLS-498">https://issues.jboss.org/browse/DROOLS-498</a>.</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div>
<div>On Jul 10, 2014, at 3:54 PM, Kent Anderson <<a
moz-do-not-send="true"
href="mailto:kent.anderson@psware.com">kent.anderson@psware.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space;
-webkit-line-break: after-white-space;">Correction: The
original post did not include another rule that exists in
the stream. The memory leak does not appear unless both
rules are active in the stream.
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span style="color: #a91500">declare</span>
MyEvent </div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"> @role(event) </div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"> @timestamp(timestamp) </div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">end<span style=""> </span></div>
</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(146, 144, 0);">/* If a RAISE is
buffered for N seconds, send it out */</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(0, 143, 0);"><span style="color:
#a91500">rule</span><span style=""> </span>"forward
raise"</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);"><span style=""><span
class="Apple-tab-span" style="white-space:pre"> </span></span>no-loop</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);"><span style=""><span
class="Apple-tab-span" style="white-space:pre"> </span></span>duration<span
style=""> (3s)</span></div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">when</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>$raise :
MyEvent(eventState == EventState.RAISE, $raiseId :
eventId)</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">then</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>System.out.println(<span
style="color: #008f00">"Forwarding RAISE("</span> +
$raiseId + <span style="color: #008f00">")"</span>);</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>delete($raise);</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">end</div>
</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(146, 144, 0);">/* When CLEAR, and
buffered, clear them both out */</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(0, 143, 0);"><span style="color:
#a91500">rule</span><span style=""> </span>"forget it
ever happened"</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);"><span style=""><span
class="Apple-tab-span" style="white-space:pre"> </span></span>no-loop</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">when</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>$clear :
MyEvent(eventState == EventState.CLEAR, $clearId :
eventId)</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>$raise :
MyEvent(eventState == EventState.RAISE, eventId ==
$clearId)</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">then</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>System.out.println(<span
style="color: #008f00">"Forgetting RAISE/CLEAR("</span>
+ $clearId + <span style="color: #008f00">")"</span>);</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>delete($clear);</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco;"><span class="Apple-tab-span"
style="white-space:pre"> </span>delete($raise);</div>
<div style="margin: 0px; font-size: 11px; font-family:
Monaco; color: rgb(169, 21, 0);">end</div>
</div>
<div><br>
</div>
<div><br>
<div>
<div>On Jul 10, 2014, at 2:50 PM, Kent Anderson <<a
moz-do-not-send="true"
href="mailto:kent.anderson@psware.com">kent.anderson@psware.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="word-wrap: break-word; -webkit-nbsp-mode:
space; -webkit-line-break: after-white-space;">The
following rule produces a memory leak in Drools
6.1.0-SNAPSHOT:
<div><br>
</div>
<div>(Stream mode)</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"><span style="color:
#a91500">declare</span> MyEvent </div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"> @role(event) </div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"> @timestamp(timestamp) </div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);">end<span
style=""> </span></div>
</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(146, 144, 0);">/*
If a RAISE is buffered for N seconds, send it
out */</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(0, 143, 0);"><span
style="color: #a91500">rule</span><span
style=""> </span>"forward raise"</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);"><span
style=""><span class="Apple-tab-span"
style="white-space:pre"> </span></span>no-loop</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);"><span
style=""><span class="Apple-tab-span"
style="white-space:pre"> </span></span>duration<span
style=""> (3s)</span></div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);">when</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre">
</span>$raise : MyEvent(eventState ==
EventState.RAISE, $raiseId : eventId)</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);">then</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre">
</span>System.out.println(<span style="color:
#008f00">"Forwarding RAISE("</span> + $raiseId
+ <span style="color: #008f00">")"</span>);</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco;"><span
class="Apple-tab-span" style="white-space:pre">
</span>delete($raise);</div>
<div style="margin: 0px; font-size: 11px;
font-family: Monaco; color: rgb(169, 21, 0);">end</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>I see the rule fire as expected, printing out
the message 3 seconds after the event is added
into the session. While the event is waiting, I
see a FactCount of 1 in the session. After the
rule fires, the fact count goes to 0. However,
using JVisualVm, querying the heap dump shows 1
instance of MyEvent, referenced by an
EventFactHandle and several other Drools objects.</div>
<div><br>
</div>
<div>Is this a bug, or is there a better way to
write this rule so Drools’ internals let go of the
object after it is no longer a fact?</div>
<div><br>
</div>
<div><span><PastedGraphic-1.png></span></div>
<div><br>
</div>
<div><span><PastedGraphic-2.png></span></div>
</div>
_______________________________________________<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">https://lists.jboss.org/mailman/listinfo/rules-users</a></blockquote>
</div>
<br>
</div>
</div>
_______________________________________________<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 class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></blockquote>
</div>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
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>