Next: Grade modifiers for single precision floats, Previous: Grade modifiers for flexible stack sizes, Up: Grade modifiers [Contents][Index]
By default, the Mercury system provides no garbage collection beyond what the target language provides. C# and Java have their own builtin garbage collectors, but C does not. Since garbage collection is essential for all programs other than those with very short runtimes, base grades that target C usually include a grade modifier that specifies which garbage collector to use.
.gc
Compiling programs in a grade that includes the .gc
grade modifier
generates executables that use the standard Mercury garbage collector,
which is the Boehm-Demers-Weiser conservative collector for C.
This grade modifier is relevant only for base grades that target C, and is compatible only with them.
The reason why this is an explicit grade modifier is that over the years, we have tried out several collectors for C. These had their own grade modifiers, to allow users to specify their use. However, only the Boehm-Demers-Weiser collector has stood the test of time.