12.3.1 Type term_t: a reference to a Prolog term
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • Interface Data Types
          • Type term_t: a reference to a Prolog term
            • PL_new_term_ref()
            • PL_new_term_refs()
            • PL_copy_term_ref()
            • PL_reset_term_refs()
            • Interaction with the garbage collector and stack-shifter
    • Packages

12.3.1.1 Interaction with the garbage collector and stack-shifter

Prolog implements two mechanisms for avoiding stack overflow: garbage collection and stack expansion. On machines that allow for it, Prolog will use virtual memory management to detect stack overflow and expand the runtime stacks. On other machines Prolog will reallocate the stacks and update all pointers to them. To do so, Prolog needs to know which data is referenced by C code. As all Prolog data known by C is referenced through term references (term_t), Prolog has all the information necessary to perform its memory management without special precautions from the C programmer.