2.4.3 Controlling the stack sizes
The default limit for the Prolog stacks is 128 MB on 32-bit and 256 MB on 64-bit hardware. The 128 MB limit on 32-bit systems is the highest possible value and the command line options can thus only be used to lower the limit. On 64-bit systems, the limit can both be reduced and enlarged. See section 2.20. Below are two examples, the first reducing the local stack limit to catch unbounded recursion quickly and the second using a big (32 GB) global limit, which is only possible on 64-bit hardware. Note that setting the limit using the command line only sets a soft limit. Stack parameters can be changed (both reduced and enlarged) at any time using the predicate set_prolog_stack/2.
$ swipl -L8m $ swipl -G32g
- -Gsize[kmg]
- Limit for the global stack (sometimes also called term stack or heap). This is where compound terms and large numbers live.
- -Lsize[kmg]
- Limit for the local stack (sometimes also called environment stack). This is where environments and choice points live.
- -Tsize[kmg]
- Limit for the trail stack. This is where we keep track of assignments, so we can rollback on backtracking or exceptions.
- -Msize[kmg]
- Limit for the table space. This is where tries holding memoized11The letter M is used because the T was already in use. It is a memnonic for Memoizing. answers for tabling are stored. The default is 1Gb on 64-bit machines and 512Mb on 32-bit machines. See the Prolog flag table_space