Next: ref-mgc-gcd, Previous: ref-mgc-mgc, Up: ref-mgc [Contents][Index]
For most programs, the default settings for the garbage collection parameters should suffice. For programs that have high global stack requirements, the default parameters may result in a higher ratio of garbage collection time to run time. These programs should be given more space in which to run.
The gc_margin
is a non-negative integer specifying the desired margin in
kilobytes. For example, the default value of 1000 means that the
global stack will not be expanded if garbage collection can reclaim at least
one megabyte. The advantage of this criterion is that
it takes into account both
the user’s estimate of the global stack usage and the effectiveness of garbage
collecting.
gc_margin
higher than the default will cause fewer global stack expansions
and garbage collections. However, it will use more space, and garbage
collections will be more time-consuming when they do occur.
Setting the margin too large will cause the global stack to expand so that if it does overflow, then the resulting garbage collection will significantly disrupt normal processing. This will be especially so if much of the global stack is accessible to future computation.
gc_margin
lower than the default will use less space, and
garbage collections will be less time-consuming. However, it will cause more
global stack expansions and garbage collections.
Setting the margin too small will cause many garbage collections in a small amount of time, so that the ratio of garbage-collecting time to computation time will be abnormally high.
The correct value for the gc_margin
is dependent upon many factors.
Here is a non-prioritized list of some of them:
The algorithm used when the global stack overflows is as follows:
ifgc
is on and the global stack has grown at leastgc_margin
kilobytes since the last garbage collection then garbage collect the global stack if less thangc_margin
kilobytes are reclaimed then try to expand the global stack endif else try to expand the global stack endif
The user can use the gc_margin
option of prolog_flag/3
to
reset the gc_margin
(see ref-lps-ove). If a garbage
collection reclaims at least the gc_margin
kilobytes of global stack space, then
the global stack is not expanded after garbage collection completes.
Otherwise, the global stack is expanded after garbage collection. This
expansion provides space for the future global stack usage that will
presumably occur. In addition, no garbage collection occurs if the
global stack has grown less than gc_margin
kilobytes since the last garbage collection.