Availability:built-in
trim_stacksRelease stack memory resources that are not in use at this moment, 
returning them to the operating system. 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 can 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. See also trim_heap/0 
and
thread_idle/2.