Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leak Sicstus Prolog

This question is a followup from this question.

I'm running a large number of tests in Sicstus prolog:

runtest:-
 t1,
 t2,
 t3,
 .
 .
 t100.

Each test is standalone and will print its result to the screen. There is no releation between the tests, so no data need to be stored/saved between each test.

My problem is that Sicstus accumulates memory and finally hits an exception: 'Resource error: insufficient memory'

I have tried to organize my test like this:

runtest:-
  once( t1 ),
  once( t2 ),
  .
  .
  once( t100 ).

But I still get into the problem.

Is there any other way to tell Prolog to free all allocated memory between each call to a test?

like image 240
MortenM Avatar asked Feb 12 '14 07:02

MortenM


2 Answers

No, there is no way to tell Prolog to free all allocated memory.

If the test predicates takes no arguments, and wrapping them in once/1 does not help, then a failure driven loop also should not help.

One possibility is that your tests somehow add persistent data, e.g. asserts clauses.

Try adding

garbage_collect, statistics

between (some of) the test. This should give you an idea about which memory areas are growing.

From looking at your earlier question, it could be that one of your tests runs out of memory all by itself, i.e. that the problem is unrelated to running multiple tests.

like image 107
Per Mildner Avatar answered Sep 26 '22 21:09

Per Mildner


Try using a (modern) failure driven loop: should reclaim memory on any Prolog

?- forall(member(T, [t1,t2,...,t100]), once(T)).
like image 24
CapelliC Avatar answered Sep 25 '22 21:09

CapelliC