[jboss-jira] [JBoss JIRA] (DROOLS-913) Memory leak when deleting a tuple from an unlinked segment

Mario Fusco (JIRA) issues at jboss.org
Mon Sep 14 11:53:00 EDT 2015


Mario Fusco created DROOLS-913:
----------------------------------

             Summary: Memory leak when deleting a tuple from an unlinked segment
                 Key: DROOLS-913
                 URL: https://issues.jboss.org/browse/DROOLS-913
             Project: Drools
          Issue Type: Bug
            Reporter: Mario Fusco
            Assignee: Mario Fusco


When deleting an object from a session all references to the object itself and the fact handle holding it should disappear. Unfortunately, as demonstrated by the test case below, in some case the deleted fact can remain as a deleted left tuple in the memory of an unlinked segment.

{code}
    @Test
    public void testBetaMemoryLeakOnFactDelete() {
        String drl =
                "rule R1 when\n" +
                "    $a : Integer(this == 1)\n" +
                "    $b : String()\n" +
                "    $c : Integer(this == 2)\n" +
                "then \n" +
                "end\n" +
                "rule R2 when\n" +
                "    $a : Integer(this == 1)\n" +
                "    $b : String()\n" +
                "then \n" +
                "end\n";

        KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
                                             .build()
                                             .newKieSession();

        FactHandle fh1 = ksession.insert(1);
        FactHandle fh2 = ksession.insert("test");
        ksession.fireAllRules();

        ksession.delete(fh1);
        ksession.delete(fh2);
        ksession.fireAllRules();

        NodeMemories nodeMemories = ((InternalWorkingMemory) ksession).getNodeMemories();
        for (int i = 0; i < nodeMemories.length(); i++) {
            Memory memory = nodeMemories.peekNodeMemory( i );
            if ( memory != null && memory.getSegmentMemory() != null ) {
                SegmentMemory segmentMemory = memory.getSegmentMemory();
                System.out.println( memory );
                LeftTuple deleteFirst = memory.getSegmentMemory().getStagedLeftTuples().getDeleteFirst();
                System.out.println( deleteFirst );
                assertNull( deleteFirst );
            }
        }
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list