Pike v8.0 release 1738

Method Pike.gc_parameters()


Method gc_parameters

mapping(string:float) gc_parameters(void|mapping(string:mixed) params)

Description

Set and get various parameters that control the operation of the garbage collector. The passed mapping contains the parameters to set. If a parameter is missing from the mapping, the current value will be filled in instead. The same mapping is returned. Thus an empty mapping, or no argument at all, causes a mapping with all current settings to be returned.

The following parameters are recognized:

"enabled" : int

If this is 1 then the gc is enabled as usual. If it's 0 then all automatically scheduled gc runs are disabled and the parameters below have no effect, but explicit runs through the gc function still works as usual. If it's -1 then the gc is completely disabled so that even explicit gc calls won't do anything.

"garbage_ratio_low" : float

As long as the gc time is less than time_ratio below, aim to run the gc approximately every time the ratio between the garbage and the total amount of allocated things is this.

"time_ratio" : float

When more than this fraction of the time is spent in the gc, aim for garbage_ratio_high instead of garbage_ratio_low.

"garbage_ratio_high" : float

Upper limit for the garbage ratio - run the gc as often as it takes to keep it below this.

"min_gc_time_ratio" : float

This puts an upper limit on the gc interval, in addition to the factors above. It is specified as the minimum amount of time spent doing gc, as a factor of the total time. The reason for this limit is that the current amount of garbage can only be measured in a gc run, and if the gc starts to run very seldom due to very little garbage, it might get too slow to react to an increase in garbage generation. Set to 0.0 to turn this limit off.

"average_slowness" : float

When predicting the next gc interval, use a decaying average with this slowness factor. It should be a value between 0.0 and 1.0 that specifies the weight to give to the old average value. The remaining weight up to 1.0 is given to the last reading.

"pre_cb" : function(:void)

This function is called when the gc starts.

"post_cb" : function(:void)

This function is called when the mark and sweep pass of the gc is done.

"destruct_cb" : function(object, int, int:void)

This function is called once for each object that is part of a cycle just before the gc will destruct it. The arguments are:

The object to be destructed.

The reason for it being destructed. One of:

Object.DESTRUCT_CLEANUP

Destructed during exit.

Object.DESTRUCT_GC

Destructed during normal implicit or explicit gc().

The number of references it had.

"done_cb" : function(int:void)

This function is called when the gc is done and about to exit. The argument is the same value as will be returned by gc().

See also

gc, Debug.gc_status