Bug 1056599 - Memory leak in phreak when a newly added fact is removed before a join node having that fact as right input is evaluated
Summary: Memory leak in phreak when a newly added fact is removed before a join node h...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: CR2
: 6.0.0
Assignee: Mario Fusco
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-22 14:38 UTC by Mario Fusco
Modified: 2014-08-06 20:19 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:19:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-411 0 Major Resolved Memory leak in nurse rostering example for dataset medium01, due to a bug in Drools 2018-05-08 09:17:22 UTC

Description Mario Fusco 2014-01-22 14:38:37 UTC
When a fact that is the right input of a join node is added and then immediately removed before the join node is evaluated it gets added to the delete staged set of the right memory of that node. If the join node never gets evaluated the right tuple will remain forever in that staged set. Iterating this process with a big numbers of these facts can ultimately lead to a OutOfMemory.

The following test case reproduces the problem. It doesn't make any assertion so it doesn't fail. Anyway putting a breakpoint in the RightTupleSetsImpl.addDelete method it is possible to see that the set has 100 RightTuple in its staged delete set.

        @Test
        public void testStagedTupleLeak() throws Exception {
            String str =
                    "rule R1 when\n" +
                    "    $i : Integer()\n" +
                    "then\n" +
                    "    insertLogical( $i.toString() );\n" +
                    "end\n" +
                    "\n" +
                    "rule R2 when\n" +
                    "    $i : Integer()\n" +
                    "then\n" +
                    "    delete( $i );\n" +
                    "end\n" +
                    "\n" +
                    "rule R3 when\n" +
                    "    $l : Long()\n" +
                    "    $s : String( this == $l.toString() )\n" +
                    "then\n" +
                    "end\n";
     
            KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
     
            for (int i = 0; i < 100; i++) {
                ksession.insert(i);
                ksession.fireAllRules();
            }
        }

Comment 2 Edson Tirelli 2014-01-22 14:50:54 UTC
This was found today and being a memory leak, we would like to include the fix in 6.0.0.CR2.

Comment 3 Mario Fusco 2014-01-22 15:31:44 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/453f0f68b

Comment 4 Mario Fusco 2014-01-22 15:45:13 UTC
This fix has been cherry-picked to both 6.0.x and 6.0.0.GA.x branches.

Comment 5 JBoss JIRA Server 2014-01-22 15:47:39 UTC
Mario Fusco <mario.fusco> updated the status of jira DROOLS-411 to Resolved

Comment 7 Lukáš Petrovický 2014-01-24 15:29:33 UTC
(In reply to Lukáš Petrovický from comment #6)
> The unit test to reproduce the issue has failed with CR2. Reopening.

The unit test DID NOT fail, mea culpa. This bug is indeed VERIFIED.


Note You need to log in before you can comment on or make changes to this bug.