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

Memory leak in stateful session after retracting facts

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Critical
    • Resolution: Done
    • 6.0.1.Final
    • 6.1.0.Final
    • None
    • None
    • Hide

      Fact Class:
      @Role(Type.FACT)
      public class Facility implements Serializable {
      private static final long serialVersionUID = 1L;
      private int id;
      private String name;
      ... getters/constructors, no setters; hashcode/equals based on id.
      }
      Inserting code
      for (int i = 1; i < 400_000; i++)

      {kieSession.insert(new Facility(i, "Fac" + i));}

      emarKS.fireAllRules();

      Deleting code:
      public class RemoveFacilities

      {private int id;...}

      RemoveFacilities toRemove = new RemoveFacilities(1);
      FactHandle fh = emarKS.insert(toRemove);
      emarKS.fireAllRules();
      emarKS.delete(fh);
      emarKS.fireAllRules();

      The deleting rule:
      rule "Remove Facilities with id above x"
      when
      RemoveFacilities($id:id)
      $fac:Facility(id>=$id)
      then
      delete($fac);
      end

      Show
      Fact Class: @Role(Type.FACT) public class Facility implements Serializable { private static final long serialVersionUID = 1L; private int id; private String name; ... getters/constructors, no setters; hashcode/equals based on id. } Inserting code for (int i = 1; i < 400_000; i++) {kieSession.insert(new Facility(i, "Fac" + i));} emarKS.fireAllRules(); Deleting code: public class RemoveFacilities {private int id;...} RemoveFacilities toRemove = new RemoveFacilities(1); FactHandle fh = emarKS.insert(toRemove); emarKS.fireAllRules(); emarKS.delete(fh); emarKS.fireAllRules(); The deleting rule: rule "Remove Facilities with id above x" when RemoveFacilities($id:id) $fac:Facility(id>=$id) then delete($fac); end

    Description

      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.

      Attachments

        1. gcRoot.png
          gcRoot.png
          32 kB
        2. memory-leak2.zip
          2.56 MB
        3. screenshot1.png
          screenshot1.png
          45 kB

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              codemonkey123 Vitaly Lomov (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: