scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Database: assert/retract leaking

Open UWN opened this issue 3 years ago • 3 comments

ulrich@p0:/opt/gupu/scryer-prolog$ ulimit -v
50000
ulrich@p0:/opt/gupu/scryer-prolog$ target/release/scryer-prolog -f
?- repeat, asserta(fact), retract(fact), fail.
memory allocation of 5636096 bytes failed
Aborted (core dumped)

UWN avatar Feb 05 '22 09:02 UWN

I think a quick scan of the call stack is sufficient to decide whether a clause can be safely removed: If the predicate does not appear in the call stack, then you can simply remove the clause entirely.

This would appear to solve this issue, and therefore most likely also #1264.

triska avatar Mar 11 '22 16:03 triska

(call stack and choice points)

Commonly, implementations start with a broken and inconsistent kind of immediate update view which still works for many uses. Then much later, they add some kind of time stamp to it. Also, facts are much less problematic than rules. After all, there is no way that a fact remains in use. It's only that there might be goals still open that need the fact upon backtracking.

UWN avatar Mar 11 '22 16:03 UWN

Note for later: Once this issue is resolved, 1fa8a0a96986e0343e54901b4d00b998068e5833 should be reverted, since the original code is shorter and (then) also cleans up better.

triska avatar Apr 03 '22 16:04 triska