2.19 System limits
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Overview
        • System limits
          • Limits on memory areas
          • Other Limits
          • Reserved Names
    • Packages

2.19.2 Other Limits

Clauses
The only limit on clauses is their arity (the number of arguments to the head), which is limited to 1024. Raising this limit is easy and relatively cheap; removing it is harder.
Atoms and Strings
SWI-Prolog has no limits on the length of atoms or strings. The number of atoms is unlimited. Atoms are subject to garbage collection. See section 12.4.2.1. Both atoms and strings can represent all Unicode code points, including 0 (\u0000). Currently, SWI-Prolog uses a separate representation for ISO Latin 1 text (code points 0 ... 255) and text that includes higher code points. The latter is represented using the C wchar_t type. On most systems this implies UCS-4, i.e., 32-bit unsigned integers. On Windows wchar_t uses UTF-16, which implies that it cannot represent the code points reserved for surrogate pairs as single code points. Future versions may switch to using UTF-8 throughout.
Nesting of terms
Most built-in predicates that process Prolog terms create an explicitly managed stack and perform optimization for processing the last argument of a term. This implies they can process deeply nested terms at constant and low usage of the C stack, and the system raises a resource error if no more stack can be allocated. This includes read/1 and write/1 and all variations thereof.
Integers
SWI-Prolog has two integer representations. Tagged integers are currently limited to 57 bits.45Before version 9.3.6, tagged integers on 32-bit systems had 25 bits and there was a third representation for 64 bit integers. Unbounded integers are by default provided by the GNU GMP library. Alternatively, they may be provided by the bundled LibBf library. The system can be built without support for unbounded integers.

The size of an unbounded integer is limited by the amount of memory that is available for the global stack, i.e., by the Prolog flag stack_limit (see section 2.19.1) and, if set, by the Prolog flag max_integer_size. If the system is built using GMP and the C type long is smaller than 64 bits, as is the case on Windows, GMP integers are in addition limited to 2^32 bits, i.e., 512Mb or about 1.3 billion decimal digits.

Arithmetic evaluation estimates the size of the result of the functions that can create big integers (**/2, ^/2, <</2, */2 and lcm/2) and raises a resource_error(stack) exception before performing the computation if the result cannot be represented.46This check cannot be omitted because GMP terminates the process if we ask it for a number that does not fit in its data types.

Floating point numbers
Floating point numbers are represented as C-native double precision floats, 64-bit IEEE on most machines.