To help me understand what is happening in the WM, I've just made a analysis
method (see below), scrutating all the RightTuples from the WM facts and
showing some stats on the 5 biggest ones :
I call it every 100 matchFired and it shows me info like:
Biggest RightTuple types :
- EvemetierData: RightTuple/NotNode[niveau == $niveau, suffixe == $suffixe]
x *209346*
- SuffixeMapDHF: RightTuple/JoinNode[id == $ev.suffixe] x 17610
- EvemetierData: RightTuple/AccumulateNode[this == $obj.father] x 14145
- EvemetierData: RightTuple/AccumulateNode[niveau == $obj.niveau,
affperiode == $obj.affperiode, typeeve_id == $obj.typeeve_id, dteve ==
$obj.dteve, $suffixeMap.toPhaseTOT != null && ( $suffixeMap.toPhaseTOT !=
null && suffixe == $suffixeMap.toPhaseTOT.id )] x 14145
- EvemetierData: RightTuple/NotNode[niveau == $niveau, suffixe == $suffixe,
sources contains $source3] x 11316
I clearly found my suspect N°1. Is there any pre-existing and better written
methods to do this kind of research in drools ?
Regards,
Benoît
Method to be called after each/N match fired or ... It uses Guava for the
collections :
private void analyzeWorkingMemoryTuples()
{
Multiset<String> keys = HashMultiset.create();
for(FactHandle handle:kieSession.getFactHandles())
{
DefaultFactHandle factHandle = (DefaultFactHandle)handle;
String
factType=factHandle.getObject().getClass().getSimpleName();
RightTuple rightTuple = factHandle.getFirstRightTuple();
while(rightTuple!=null)
{
String key = factType + ": RightTuple";
BetaNode sink =
(BetaNode)rightTuple.getRightTupleSink();
if (sink!=null) {
key+= "/" + sink.getClass().getSimpleName();
key+=Arrays.toString(sink.getConstraints());
}
keys.add(key);
rightTuple = rightTuple.getHandleNext();
}
}
ArrayList<Multiset.Entry<String>> entries =
Lists.newArrayList(keys.entrySet());
Collections.sort(entries, new
Comparator<Multiset.Entry<String>>(){
@Override
public int compare(Entry<String> o1, Entry<String> o2)
{
return -Integer.compare(o1.getCount(), o2.getCount());
}
});
String analysis = Joiner.on("\n -
").join(Iterables.limit(entries, 5));
if (!analysis.equals(previousAnalysis))
{
logger.info("Biggest RightTuple types :\n - " + analysis);
previousAnalysis = analysis;
}
}
--
View this message in context:
http://drools.46999.n3.nabble.com/Analysing-OutOfMemory-too-many-RightTup...
Sent from the Drools: User forum mailing list archive at
Nabble.com.