Release stack memory resources that are not in use at this moment,
returning them to the operating system. Trim stack is a relatively cheap
call. It can be used to release memory resources in a backtracking loop,
where the iterations require typically seconds of execution time and
very different, potentially large, amounts of stack space. Such a loop
should be written as follows:
loop :-
generator,
trim_stacks,
potentially_expensive_operation,
stop_condition, !.
The prolog top level loop is written this way, reclaiming memory
resources after every user query.
Set a parameter for a runtime stack. Stack is one of
local
, global
, trail
or argument
.
The table below describes the Key/Value pairs.
- low
-
Do not perform GC below this amount (bytes).
- factor
-
Run next GC if memory exceeds max(low,checked) × factor.
- min_free
-
Enlarge stack if free memory is below this value (bytes). This option is
only provided if the system is compiled to support the stack-shifter;
otherwise it is silently ignored.
Not all flags have impact for all stacks and the current
implementation lacks proper checking for sensible values. Use with
extreme care.