-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
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.
@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 ); } } }