SICStus Prolog stores some information in named variables called system properties. System properties are used since release 4.1, whereas previous releases used environment variables.
The default value when reading a system property is taken from the corresponding environment variable. This makes system properties largely backward compatible with how environment variables were used in previous releases. Any exceptions to this rule are explicitly mentioned in the documentation.
You can obtain the value of system properties and environment variables
using system:environ/[2,3]
(see lib-system) and
SP_getenv()
.
Some system properties affect the SICStus Prolog initialization process and must therefore be set before SICStus Prolog has been initialized. There are three ways to affect the initial values of system properties:
System properties get their default value from the environment so this is often a convenient method. It was the only method available prior to release 4.1.
SP_initialize()
if you initialize
the SICStus runtime from C. See Initializing the Prolog Engine.
Looking up system properties follows the platform convention for environment variables. This means that the lookup is case sensitive on UNIX-like platforms and case insensitive on Windows.
On UNIX-like systems, the environment is assumed to use the UTF-8 character encoding; on Windows, the native Unicode encoding is used.
SICStus reads and copies the process environment during
initialization, e.g. in SP_initialize()
. Any subsequent
changes to the proces environment will not be detected by
SICStus. Note that, at least on UNIX-like systems, changing the
process environment, e.g. using setenv()
, has undefined behavior
when the process has multiple threads, which is the case for any
process running SICStus.
While copying the environment, each entry in the environment is normalized as follows:
In particular, on UNIX-like systems, this means that the environment should preferably be in UTF-8.
The following system properties are set automatically on startup.
application
file search path.
runtime
file search path.
library
file search path.
open/4
option
if_exists(generate_unique_name)
.
Also available as the temp
file search path.
SP_STARTUP_DIR
system property will be
set to the working directory used by SICStus.
Note that this system property can also be set prior to initialization, in order to tell SICStus which working directory to use. See below.
The following system properties can be set before starting SICStus Prolog.
Some of these override the default sizes of certain areas. For variables ending with ‘SIZE’, the size is in bytes, but may be followed by ‘K’, ‘M’, or ‘G’ meaning 2**10, 2**20 and 2**30 respectively.
This value of this system property is not read from the
corresponding environment variable.
The sizes of the two data areas are constrained to take certain
discrete values only. The initial size as well as the size after
expansion is constrained to be w*((1+g)^n) kilobytes, rounded up
to an integral number of words, where w is the word length in
bits, g is GROWTHFACTOR/100, and n is an integer.
SP_deinitialize()
is called or the
process exits.
trimcore/0
. By default, Prolog gets memory from the O/S as the
user program executes, whereas trimcore/0
endeavors to return
free memory back to the O/S. If the programmer knows that her
program, once it has grown to a certain size, is likely to need as
much memory for future computations, she can advise Prolog not to
return all the free memory back to the operating system by setting
this variable. trimcore/0
only endeavors to return memory that is
allocated above and beyond PROLOGKEEPSIZE; the rest will be
kept. Only used by the default memory allocator
(see SP_set_memalloc_hooks).
Please note: The initially allocated memory will be kept by
the Prolog process forever, so it is not meaningful to set
PROLOGKEEPSIZE smaller than PROLOGINITSIZE.
unlimited
or a numeric value as described in the
first paragraph in this section. A numeric value of zero (0) is
equivalent to unlimited
. Not used under Windows.
yes
then malloc()
et al. will be used for memory
management instead of the default memory allocator. This is sometimes
useful, e.g$: with debugging tools like
valgrind. Corresponds to the -m flag to
sicstus and the --userhook=malloc flag to
spld (see SP_set_memalloc_hooks).
See Memory Use and Garbage Collection for more information.
In addition some system properties are read during normal execution. In
this case the system property is typically not meant to be explicitly
set, instead the value is intended to be taken from the corresponding
environment variable. Examples of such system properties include
PATH and HOME
.