[jboss-jira] [JBoss JIRA] (DROOLS-498) Memory leak in stateful session after retracting facts
Kent Anderson (JIRA)
issues at jboss.org
Fri Jul 11 15:57:24 EDT 2014
[ https://issues.jboss.org/browse/DROOLS-498?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kent Anderson updated DROOLS-498:
---------------------------------
Attachment: memory-leak2.zip
This appears to be a similar issue to one we have found when rules with temporal patterns interact with other rules. (Drools 6.1.0.CR2)
The attached memory-leak2.zip file contains a maven/Eclipse project that can be run using mvn exec:exec, or from Eclipse using the "MemoryLeak Demo" launch configuration (included).
The example rules implement a network monitor algorithm that suppresses alarms that get auto-cleared by the network within a certain amount of time (don't bother an operator if it's not really a problem).
The sample app sends in three events: Raise(1), Clear(1), Raise(2). All rules fire as expected, and the fact count goes to 0. However, a heap dump (also included in the zip file) shows the final Raise(2) (MyEvent.java) still referenced in memory (using jvisualvm).
Just having a rule with a @duration(3s) doesn't cause the memory leak. However, when a rule is added to the session that checks for the existence of a Clear while its corresponding Raise is still in memory, the object is retained, even after being removed from Working Memory.
A workaround exists, which removes the check for the Raise event from the LHS and moves it to a query, which is called from the RHS. This solves the problem, but makes for bad practice in the rules (per the Drools docs).
http://drools.46999.n3.nabble.com/rules-users-EventFactHandle-retained-in-memory-after-FactCount-reaches-0-for-temporal-based-rule-td4030294.html
> Memory leak in stateful session after retracting facts
> ------------------------------------------------------
>
> Key: DROOLS-498
> URL: https://issues.jboss.org/browse/DROOLS-498
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 6.0.1.Final
> Reporter: Vitaly Lomov
> Assignee: Mark Proctor
> Priority: Minor
> Attachments: memory-leak2.zip, screenshot1.png
>
>
> After adding many simple facts into the stateful session and then removing them, the factHandles for the removed facts are still referenced by the session. Eventually getting "java.lang.OutOfMemoryError: GC overhead limit exceeded" with the stack trace (sometimes) similar to DROOLS-411.
> Someone on StackOverflow suggested iterating through whatever factHandles remain after deletion and delete those, but I get no factHandles (correct, since I removed all facts).
> See screenshot for objects in memory _after_ deleting all facts.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list