<html><body 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="color: #000000">&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="color: #000000"> </span>"forward raise"</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);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>duration<span style="color: #000000"> (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’ internals let go of the object after it is no longer a fact?</div><div><br></div><div><img apple-inline="yes" id="92AF1B1A-893B-499E-824F-981104C4E3D6" height="629" width="1118" apple-width="yes" apple-height="yes" src="cid:FDADB942-B3AC-48D3-A376-EC1F4CCBB348@SSG-520"></div><div><br></div><div><img apple-inline="yes" id="8E7F6B9D-DFCE-4953-A403-5CE4A5D88F9E" height="628" width="1118" apple-width="yes" apple-height="yes" src="cid:033ED0AE-76A6-419A-96D1-B4614C44E331@SSG-520"></div></body></html>