With this program:
:- table words/2.
words([],0).
words([W|Ws],N) :-
N #> 0,
N1 #= N - 1,
word(W),
words(Ws,N1).
word("hi").
word("ho").
table_mem(Bytes) :-
aggregate_all(sum(Bytes1),
( current_table(_,Table),
trie_property(Table,size(Bytes1))
),
Bytes).
And the following queries:
2 ?- table_mem(Bytes).
Bytes = 0.
3 ?- shell("free -h").
total used free shared buff/cache available
Mem: 23Gi 4.6Gi 10Gi 602Mi 8.2Gi 17Gi
Swap: 4.0Gi 0B 4.0Gi
true.
4 ?- words(W,20),fail.
false.
5 ?- table_mem(Bytes).
Bytes = 788527096.
6 ?- shell("free -h").
total used free shared buff/cache available
Mem: 23Gi 5.6Gi 9.6Gi 602Mi 8.2Gi 16Gi
Swap: 4.0Gi 0B 4.0Gi
true.
7 ?- abolish_all_tables.
true.
8 ?- table_mem(Bytes).
Bytes = 0.
9 ?- shell("free -h").
total used free shared buff/cache available
Mem: 23Gi 5.6Gi 9.6Gi 602Mi 8.2Gi 16Gi
Swap: 4.0Gi 0B 4.0Gi
true.
abolish_all_tables
is not returning all the memory to the OS. The table memory seems to be realeased (table_mem(0)
is true), but it doesn’t seem to be returned to the OS. Am I missing something?
P.S. This is with the latest commit including dynamic tabling (8.1.8-128-g076e59f24).