4.42 Memory Management
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Memory Management
          • garbage_collect/0
          • garbage_collect_atoms/0
          • garbage_collect_clauses/0
          • set_prolog_gc_thread/1
          • trim_stacks/0
          • set_prolog_stack/2
          • prolog_stack_property/2
    • Packages
Availability:built-in
trim_stacks
Release 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.