Memory leak after retracting fact

Solution Verified - Updated -

Issue

When executing following drl file (Constraint_Error.drl)

package com.sample;

import java.util.Date;
import com.sample.Constraint_Error.Person;
import com.sample.Constraint_Error.Job;
import com.sample.Constraint_Error.Modification;

rule "Insert Job"
    when
        p : Person()
        not Job(name == "Worker", holder == p)
    then
        insert(new Job("Worker", p));
        System.out.printf("Inserted Job for %s%n", p.getName());
end

rule "Retract Job"
    when
        j : Job(name == "Worker", h : holder)
        not Person(this == h)
    then
        retract(j);
        System.out.printf("Retracting Job for %s%n", h.getName());
end

rule "Moved away"
    when
        m : Modification(kind == "Moved away")
        p : Person(name == m.name)
    then
        retract(p);
        retract(m);
        System.out.printf("Person %s has moved away%n", m.getName());
end

rule "Invalid Modification"
    when
        m : Modification()
        not Person(b : dateOfBirth, getAge(b) < 200, name == m.name)
    then
        retract(m);
        System.out.printf("Received an modification that applies to no one%n");
end

function Integer getAge(Date dateOfBirth) {
    int add = 0;
    Date today = new Date();
    if (new Date(today.getYear(), dateOfBirth.getMonth(), dateOfBirth.getDay()).after(today)) {
        add = -1;
    }
    return today.getYear() - dateOfBirth.getYear() + add;
}

this issue occurs:

debug

Execution is stopped on the last line to inspect the heap. According to the drl-file there should be no
person, job or modification object left in memory as all have been retracted and no references are
kept.

heap.png
As this screenshot from VisualVM shows the person object (Alice) still lingers in memory.

Environment

  • Red Hat JBoss BRMS 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content