scryer-prolog
scryer-prolog copied to clipboard
clpz: space leak
g1b:/tmp> /opt/gupu/scryer-prolog/target/release/scryer-prolog -f
?- use_module(library(between)).
true.
?- use_module(library(clpz)).
true.
?- between(0,100000,N),([A,B]ins-3..3,A^B#>9,labeling([],[A,B]),false;N mod 1000=:=0,Countonly=true).
N = 0, Countonly = true
; N = 1000, Countonly = true
; N = 2000, Countonly = true
; N = 3000, Countonly = true
; N = 4000, Countonly = true
; N = 5000, Countonly = true
; N = 6000, Countonly = true
; N = 7000, Countonly = true
; N = 8000, Countonly = true
; N = 9000, Countonly = true
; N = 10000, Countonly = true
; N = 11000, Countonly = true
; N = 12000, Countonly = true
; N = 13000, Countonly = true
; N = 14000, Countonly = true
; N = 15000, Countonly = true
; N = 16000, Countonly = true
; N = 17000, Countonly = true
; N = 18000, Countonly = true
; N = 19000, Countonly = true
; N = 20000, Countonly = true
; N = 21000, Countonly = true
; N = 22000, Countonly = true
; N = 23000, Countonly = true
; N = 24000, Countonly = true
; N = 25000, Countonly = true
; N = 26000, Countonly = true
; N = 27000, Countonly = true
; N = 28000, Countonly = true
; N = 29000, Countonly = true
; N = 30000, Countonly = true
; ^C error('$interrupt_thrown',repl/0).
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ulrich 935676 0.9 0.0 1742324 26856 pts/36 Sl+ 20:43 0:00 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f
ulrich 935676 56.7 0.0 1743248 27972 pts/36 Rl+ 20:43 3:07 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f
ulrich 935676 58.9 0.0 1744172 29028 pts/36 Sl+ 20:43 3:49 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f
No such problem when using A^B#>27 instead of A^B#>9 in
?- between(0,1000000,N),([A,B]ins 0..3,A^B#>27,labeling([],[A,B]),false;N mod 10000=:=0,Countonly=true).
So far minimal leaking query:
?- between(0,1000000,N),(B in -1..0,-1^B#>9,B= -1;N mod 10000=:=0,Countonly=true).
N = 0, Countonly = true
; N = 10000, Countonly = true
; N = 20000, Countonly = true
; ...
; N = 170000, Countonly = true
; N = 180000, Countonly = true
; ^C error('$interrupt_thrown',repl/0).
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ulrich 938605 8.6 0.0 1742316 26812 pts/30 Sl+ 09:04 0:00 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f -g use_module(library(between)),use_module(library(clpz))
ulrich 938605 72.9 0.0 1749312 34372 pts/30 Rl+ 09:04 1:15 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f -g use_module(library(between)),use_module(library(clpz))
ulrich 938605 71.6 0.0 1750632 35692 pts/30 Sl+ 09:04 1:25 /opt/gupu/scryer-prolog/target/release/scryer-prolog -f -g use_module(library(between)),use_module(library(clpz))
$ sh -c 'ulimit -v 100000; ./scryer-prolog -f'
?- [user].
query :- repeat, _ is (2^64+1)-2^64, false.
?- query.
ulrich@p0:/opt/gupu/scryer-prolog$ sh -c 'ulimit -v 300000; time target/release/scryer-prolog -f'
?- repeat, _ is (2^64+1)-2^64, false.
thread 'main' panicked at 'out of memory', /home/ulrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dashu-int-0.4.0/src/error.rs:15:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
memory allocation of 56 bytes failed
Command terminated by signal 6
2.70user 0.12system 0:13.18elapsed 21%CPU (0avgtext+0avgdata 58604maxresident)k
0inputs+0outputs (0major+14737minor)pagefaults 0swaps
Please note that this leak makes testing of clpz barely possible
@notoria's problems are gone, and the original problem now produces:
?- between(0,1000000,N),(B in -1..0,-1^B#>9,B= -1;N mod 10000=:=0,Countonly=true).
N = 0, Countonly = true
; N = 10000, Countonly = true
; N = 20000, Countonly = true
; ...
; N = 760000, Countonly = true
; N = 770000, Countonly = true
; memory allocation of 72 bytes failed
Aborted (core dumped)
ulrich@p0:~$ ulimit -v
300000