scryer-prolog
scryer-prolog copied to clipboard
Database: assert/retract leaking
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)
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.
(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.
Note for later: Once this issue is resolved, 1fa8a0a96986e0343e54901b4d00b998068e5833 should be reverted, since the original code is shorter and (then) also cleans up better.