[rules-dev] Potential multi thread error and "smal" memory leak

Yves Galante yves.galante at jmob.net
Fri Jan 25 20:03:38 EST 2008


Hi,

Class VariableContextEntry and ReturnValueContextEntry are instantiated 
when Package.addRule called.
This class are linked from "Package rules".

         "Package => ... =>  VariableContextEntry

But class have a reference  to the InternalWorkingMemory !

         "Package => ... => VariableContextEntry => Workingmemory"

When this pseudo code is executed, at the end of the execution, 
WorkingMemory need to be garbage collected, but it isn't because she is 
referenced by ReturnValueContextEntry and/or VariableContextEntry, and 
this class keeps an reference to the WorkingMemory.

I think this can be generate some error in multi thread and make an 
"smal" memory leak.

It is right ?
The membre workingMemory can't be removed from 
VariableContextEntry/ReturnValueContextEntry ?
____________________

pseudo code (source : ReteooMannersTest)  :

final Package ruleBase = new Package( "org.drools.examples.manners" );
ruleBase.addRule( getAssignFirstSeatRule() );
...
SatefulSession session = ruleBase.newStatefulSession(false);
session.insert(new Count(1));
session.fireAllRules();
session.dispose();
session = null;
System.gc();

After GC,  workingMemory (session) need to be finally but she isn't 
because VariableContextEntry/ReturnValueContextEntry keep a reference at 
the workingMemory.

Thanks for your response

Yves





More information about the rules-dev mailing list