<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><a href="https://github.com/droolsjbpm/drools/pull/358">https://github.com/droolsjbpm/drools/pull/358</a><div><br></div><div>Per your advice, this pull request sets up the memory leak, but it cannot verify that it exists without diving into internal drools structures. </div><div><br></div><div>Please let me know what else we can do to facilitate fixing this issue.</div><div><br></div><div><br><div><div>On Jul 14, 2014, at 2:09 PM, Davide Sottara <dsotty@gmail.com> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="moz-cite-prefix">I'd need to check, but if you can put together the basics of the test case - the combination of rules and facts that causes the leak,<br>we'll add the checks to ensure it's solved. Mark should have given you enough pointers to the style we use for test cases.<br>We really appreciate your collaboration, and since this is a critical bug we'll fix it asap<br>Thanks!!<br>Davide<br><br>On 07/14/2014 08:33 PM, Kent Anderson wrote:<br></div><blockquote cite="mid:01270600-46E6-4E40-8C62-59EE72914126@psware.com" type="cite">Is there a reliable way to find an EventFactHandle instance buried within the TupleEntryQueue’s and the PhreakPropagationContext’s?<div><br></div><div>The multiple containers of interface/impl’s makes it nearly impossible to write a “good” test that can peak under the hood where this memory leak is being held. If there is a recommended way to do it, I’d be happy to do so.</div><div><br></div><div><div><br></div><div><span><Mail Attachment.png></span></div><div><br></div><div><br><div><div>On Jul 13, 2014, at 7:31 PM, Mark Proctor <<a moz-do-not-send="true" href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</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;">Could you submit a unit test as a pull request?<div><a moz-do-not-send="true" href="http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html">http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html</a></div><div><br></div><div>Add it to here, and follow existing conventions:</div><div><a moz-do-not-send="true" href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/CepEspTest.java</a></div><div><br></div><div>Mark<br><div><div>On 11 Jul 2014, at 20:38, 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;"><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: rgb(169, 21, 0);">query</span><span class="Apple-converted-space"> </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: rgb(169, 21, 0);">rule</span><span> </span>"process clear"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0);"><span><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 class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">"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: rgb(169, 21, 0);">if</span><span class="Apple-converted-space"> </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 class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">"Forwarding CLEAR("</span><span class="Apple-converted-space"> </span>+ $clearId +<span class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">")"</span><span class="Apple-converted-space"> </span>); </div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-converted-space"> </span><span style="color: rgb(169, 21, 0);">else</span><span class="Apple-converted-space"> </span>{</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span class="Apple-converted-space"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(<span style="color: rgb(0, 143, 0);">"Forgetting RAISE/CLEAR("</span><span class="Apple-converted-space"> </span>+ $clearId +<span class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">")"</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-converted-space"> </span><span style="color: rgb(169, 21, 0);">for</span><span class="Apple-converted-space"> </span>(QueryResultsRow row : results){</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span class="Apple-converted-space"> </span><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: rgb(0, 143, 0);">"$raise"</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"> <span class="Apple-converted-space"> </span><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"><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: rgb(169, 21, 0);">declare</span><span class="Apple-converted-space"> </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> </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: rgb(169, 21, 0);">rule</span><span> </span>"forward raise"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0);"><span><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><span class="Apple-tab-span" style="white-space: pre;"> </span></span>duration<span><span class="Apple-converted-space"> </span>(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: rgb(0, 143, 0);">"Forwarding RAISE("</span><span class="Apple-converted-space"> </span>+ $raiseId +<span class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">")"</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: rgb(169, 21, 0);">rule</span><span> </span>"forget it ever happened"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0);"><span><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: rgb(0, 143, 0);">"Forgetting RAISE/CLEAR("</span><span class="Apple-converted-space"> </span>+ $clearId +<span class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">")"</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: rgb(169, 21, 0);">declare</span><span class="Apple-converted-space"> </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> </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: rgb(169, 21, 0);">rule</span><span> </span>"forward raise"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0);"><span><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><span class="Apple-tab-span" style="white-space: pre;"> </span></span>duration<span><span class="Apple-converted-space"> </span>(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: rgb(0, 143, 0);">"Forwarding RAISE("</span><span class="Apple-converted-space"> </span>+ $raiseId +<span class="Apple-converted-space"> </span><span style="color: rgb(0, 143, 0);">")"</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.<span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span> <span class="Apple-converted-space"> </span> 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 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>_______________________________________________<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></div></div><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>_______________________________________________<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">https://lists.jboss.org/mailman/listinfo/rules-users</a></div></blockquote></div><br></div></body></html>