collectgarbage |
---|
Summary Collects garbage Prototype
Description Note that this has changed considerably since Lua 5.0. "stop": stops the garbage collector. "restart": restarts the garbage collector. "collect": performs a full garbage-collection cycle (this is the default if no option supplied) "count": returns the total memory in use by Lua (in Kbytes). "step": performs a garbage-collection step. The step "size" is controlled by arg (larger values mean more steps) in a non-specified way. If you want to control the step size you must experimentally tune the value of arg. Returns true if the step finished a collection cycle. "setpause": sets arg/100 as the new value for the pause of the collector (see below). "setstepmul": sets arg/100 as the new value for the step multiplier of the collector (see below). Lua implements an incremental mark-and-sweep collector. It uses two numbers to control its garbage-collection cycles: the garbage-collector pause and the garbage-collector step multiplier. The garbage-collector pause controls how long the collector waits before starting a new cycle. Larger values make the collector less aggressive. Values smaller than 1 mean the collector will not wait to start a new cycle. A value of 2 means that the collector waits for the total memory in use to double before starting a new cycle. The step multiplier controls the relative speed of the collector relative to memory allocation. Larger values make the collector more aggressive but also increase the size of each incremental step. Values smaller than 1 make the collector too slow and may result in the collector never finishing a cycle. The default, 2, means that the collector runs at "twice" the speed of memory allocation. Both "setpause" and "setstepmul" get percentage points as arguments (so an argument of 100 means a real value of 1). Both default to 200 when Lua starts up (and since they are divided by 100, effectively the default is 2 as described above).
See Also ... Lua functions
assert - Asserts that condition is not nil and not false
Topics
Lua base functions
(Help topic: lua=collectgarbage) |
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.