On 04/10/2011 22:51, alopez wrote:
Good news, I followed your advice and patched drools-core to prevent
this,
focusing on removing all listeners:
AbstractWorkingMemory.java, line 1246:
for ( Iterator it = this.__ruleBaseEventListeners.iterator(); it.hasNext();
) {
this.ruleBase.removeEventListener( (RuleBaseEventListener) it.next()
);
}
I changed that to:
for ( Iterator it = this.ruleBase.getRuleBaseEventListeners().iterator();
it.hasNext(); ) {
this.ruleBase.removeEventListener( (RuleBaseEventListener) it.next()
);
}
And now works OK, no memory leak.
That is not safe, and incorrect.
__ruleBaseEventListener is the list of
rulebase listeners that the current WM adds ot the rulebase.
public void addEventListener(RuleBaseEventListener listener) {
this.ruleBase.addEventListener( listener );
this.__ruleBaseEventListeners.add( listener );
}
When the WM is disposed it should remove it's listeners only. so it
iterates __ruleBaseEventListener to find those, and remove them from the
rulebase .
What you are doing is iterating the rulebase and removing ALL it's
listeners, which means it'll remove listeners that belong to other wms.
If you are getting a leak like this, it means some how the wm is adding
listener, that is not removed - i.e. a listener is not added to
__ruleBaseEventListener but is still added to rulebase.
If you want this fixed for 5.3, we need a test producing the issue by
today.
Mark
Thanks
--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-Memory-leak-in-5-2-5-3-tp32...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users