Open Jean-Luc-Picard-2021 opened 1 month ago
Yeah it can also crash your Prolog system:
$ ~/go/bin/1pl
Top level for ichiban/prolog v1.2.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- ['bomb.p'].
true.
?- foo.
runtime: out of memory: cannot allocate 4194304-byte block (802816000 in use)
Thats the source code:
I'm not sure if I understand your question but you can turn off GC with debug.SetGCPercent()
:
prev := debug.SetGCPercent(-1)
defer func() {
_ = debug.SetGCPercent(prev)
}()
debug.SetGCPercent is only Go GC? Usually the host language GC is not enough for a Prolog system, you need additional algorithms to trim the environment, make
the variable trailing list smaller. Basically there are WAMs with this feature and WAMs without this feature. But environment trimming was already described in early WAM papers.
For example Scryer Prolog doesn't have Prolog GC yet. Whereas SWI-Prolog has a quite good Prolog GC.
So in SWI-Prolog you can run the bomb example indefinitely it will not crash, because it has Prolog GC.
I'm afraid that this library is not based on WAM.
Lets say this feature request would be realized:
feature request time/1 and/or statistics/2 predicate https://github.com/ichiban/prolog/issues/327
What would I measure a Prolog system with or without garbage collection? Is this documented somewhere?
For example Scryer Prolog has no garbage collection, and it still fails with this test case:
The above preferably runs indefinitely. For example SWI-Prolog can run it indefinitely.