Fix leak of LogicalState in Occurrence observers: properly terminate occ-s

This commit is contained in:
Grigorii Kirgizov 2020-12-15 15:56:48 +03:00
parent ba8ccfce03
commit bd25263eac
2 changed files with 4 additions and 6 deletions

View File

@ -65,11 +65,9 @@ class Occurrence (observable: LogicalStateObservable,
override fun parentUpdated(logical: Logical<*>, controller: Controller) = doReactivate(controller)
fun terminate(observable: LogicalStateObservable) {
if (alive) {
for (a in arguments) {
if (a is Logical<*>) {
observable.removeForwardingObserver(a, this)
}
for (a in arguments) {
if (a is Logical<*>) {
observable.removeForwardingObserver(a, this)
}
}
alive = false

View File

@ -211,10 +211,10 @@ internal class EvaluationSessionImpl private constructor (
val outputOccurrences = histView.filterOccurrences(inputStore)
// todo: make output store in other processing strategies?
outputOccurrences.forEach{ it.terminate(logicalState) }
processing.resetStore() // clear observers
// todo: need clearing occurrenceContractObservers? (MPSCR-66)
logicalState.reset()
outputOccurrences.forEach{ it.terminate(logicalState) }
val rules = ruleIndex.toRules().filter(preambleInfo::inPreamble)