<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">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">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      Is there a reliable way to find an EventFactHandle instance buried
      within the TupleEntryQueue&#8217;s and the PhreakPropagationContext&#8217;s?
      <div><br>
      </div>
      <div>The multiple containers of interface/impl&#8217;s makes it nearly
        impossible to write a &#8220;good&#8221; test that can peak under the hood
        where this memory leak is being held. &nbsp;If there is a recommended
        way to do it, I&#8217;d be happy to do so.</div>
      <div><br>
      </div>
      <div>
        <div><br>
        </div>
        <div><img apple-inline="yes"
            id="D2619309-FE49-4E28-8CAE-16BC1188C467" apple-width="yes"
            apple-height="yes"
            src="cid:part1.00030605.08000602@gmail.com" height="390"
            width="813"></div>
        <div><br>
        </div>
        <div><br>
          <div>
            <div>On Jul 13, 2014, at 7:31 PM, Mark Proctor &lt;<a
                moz-do-not-send="true"
                href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;
              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;">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 &lt;<a
                        moz-do-not-send="true"
                        href="mailto:kent.anderson@psware.com">kent.anderson@psware.com</a>&gt;
                      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;">
                        <div>We have found a workaround that eliminates
                          the leftover event (gone from Working Memory,
                          but not from the JVM memory):&nbsp;</div>
                        <div><br>
                        </div>
                        <div>The rule &#8220;forget it ever happened&#8221; (seen
                          below) causes the problem. &nbsp;Re-writing it to
                          remove the check for RAISE in the LHS
                          eliminated the memory leak. &nbsp;Of course, our
                          application requires the check for RAISE, so
                          it can be accomplished by manually querying
                          working memory from the RHS. &nbsp;It&#8217;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=""> </span>"process clear"</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; 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) {&nbsp;</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> );&nbsp;</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;">&nbsp; &nbsp; &nbsp; &nbsp; <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>&nbsp; &nbsp; &nbsp; &nbsp; <span
                              style="color: #a91500">for</span>
                            (QueryResultsRow row : results){</div>
                          <div style="margin: 0px; font-size: 11px;
                            font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; <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;">&nbsp; &nbsp; &nbsp; &nbsp; <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&nbsp;<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 &lt;<a moz-do-not-send="true"
                              href="mailto:kent.anderson@psware.com">kent.anderson@psware.com</a>&gt;
                            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:
                              &nbsp;The original post did not include another
                              rule that exists in the stream. &nbsp;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&nbsp;</div>
                                <div style="margin: 0px; font-size:
                                  11px; font-family: Monaco;">&nbsp;
                                  @role(event)&nbsp;</div>
                                <div style="margin: 0px; font-size:
                                  11px; font-family: Monaco;">&nbsp;
                                  @timestamp(timestamp)&nbsp;</div>
                                <div style="margin: 0px; font-size:
                                  11px; font-family: Monaco; color:
                                  rgb(169, 21, 0);">end<span style="">&nbsp;</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 &lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:kent.anderson@psware.com">kent.anderson@psware.com</a>&gt;
                                    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&nbsp;</div>
                                        <div style="margin: 0px;
                                          font-size: 11px; font-family:
                                          Monaco;">&nbsp; @role(event)&nbsp;</div>
                                        <div style="margin: 0px;
                                          font-size: 11px; font-family:
                                          Monaco;">&nbsp;
                                          @timestamp(timestamp)&nbsp;</div>
                                        <div style="margin: 0px;
                                          font-size: 11px; font-family:
                                          Monaco; color: rgb(169, 21,
                                          0);">end<span style="">&nbsp;</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.
                                        &nbsp;While the event is waiting, I
                                        see a FactCount of 1 in the
                                        session. &nbsp;After the rule fires,
                                        the fact count goes to 0.
                                        &nbsp;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&#8217; internals let go of the
                                        object after it is no longer a
                                        fact?</div>
                                      <div><br>
                                      </div>
                                      <div><span>&lt;PastedGraphic-1.png&gt;</span></div>
                                      <div><br>
                                      </div>
                                      <div><span>&lt;PastedGraphic-2.png&gt;</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>
  </body>
</html>