- Method gc_parameters
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:
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.
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.
When more than this fraction of the time is spent in the gc, aim for garbage_ratio_high instead of garbage_ratio_low.
Upper limit for the garbage ratio - run the gc as often as it takes to keep it below this.
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.
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.
This function is called when the gc starts.
This function is called when the mark and sweep pass of the gc is done.
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:
Destructed during exit.
Destructed during normal implicit or explicit gc().
The number of references it had.
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