This is a follow up on my previous question. I have a decision tree in the following form:
and I want to transform it into rules in Drools Expert. The use of insertLogical
has been proposed. Drools documentation says this about insertLogical
:
insertLogical(new Something())
; is similar to insert, but the object will be automatically retracted when there are no more facts to support the truth of the currently firing rule.
The fact that these objects are retracted is useful (as I'll have tens of thousands of objects in memory and each will create a bunch of these). There's also a method retract(object)
, which removes an object from working memory. When I get to an end node and remove (retract
) the base object that would get there (following the decision tree), does it also remove all these temporary objects created with insertLogical
during the traversal?
From my experience the answer is No, the only object you've pointed to will be retracted from Drools working memory while all the cross-object references will be kept in JVM memory. You could even re-inject retracted object back if you keep object's reference somewhere.