Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1028

Drools 6.3.0.Final - high memory usage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Major
    • None
    • 6.1.0.Final, 6.3.0.Final
    • core engine
    • None
    • NEW
    • NEW

    Description

      We have an application that completely wraps the drools run-time. The code creates rules, compiles them and manages the run-time. We are experiencing very high memory utilization in an environment with about 1000 rules. Memory continuously grows as we insert facts, I know this is expected, however the amount of growth seems unusually large. In one scenario, memory consumption jumps 200 MB after inserting about 4800 facts (each fact consumes about 200 bytes) and calling fireallrules. We are currently running with the phreak algorithm. I wrote some code that iterates over the facthandles to count the number of right tuple references once the insertion and fireallrules has completed. It shows over 10 million references. Can someone review the attached code to tell me if the approach is sound? Also, how do I identify the entire set of right tuples in memory, I would like to write some code to produce some data about them to give me some insight into what is causing so many right tuples and right tuple references to be created. If we can narrow this down, I would like to write a reproducer to isolate the large memory usage.

      for (Object obj : kSession.getObjects()) {
      if (obj == null)

      { RuleLogger.traceDebug( className, methodName,"Null object"); }


      DefaultFactHandle factHandle = (DefaultFactHandle)kSession.getFactHandle(obj);
      if (factHandle != null) {
      RightTuple previous = factHandle.getLastRightTuple();
      int rtCount = 0;
      if (previous != null ) {
      ++rtCount;
      while (true)

      { previous = (RightTuple) previous.getNext(); if (previous == null) break; ++rtCount; }

      }
      totalRighttuples += rtCount;
      }
      }
      ...
      String msg = "printStats() - WM has " nm.length() + " nodes in NM array, " + activeNodesInNm + " active nodes, " + totalsmNetworkNodes " network nodes, " + totalsmPathMemories + " path memories, " +
      + totalRighttuples + " rightTuple references";
      Sample output:
      printStats() - WM has 14328 nodes in NM array, 4711 active nodes, 26396 network nodes, 4640 path memories, 10754655 rightTuple references

      Attachments

        1. newSampleFile.drl
          72 kB
        2. SampleRuleFile.drl
          75 kB
        3. screenshot-1.png
          screenshot-1.png
          63 kB

        Activity

          People

            mfusco@redhat.com Mario Fusco
            billt408_jira Bill Tuminaro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: