Type Function Library (globals) Return value none Revision Current Public Release (2016.2992) Keywords garbage collection, garbage, memory, resources
A generic interface to Lua's garbage collector. Using this function is not required because Lua has automatic garbage collection features.
collectgarbage( [opt [, arg]] )
String. Performs garbage collection functions differently based on this option. Acceptable values include:
"collect"— performs a full garbage-collection cycle. This is the default option.
"stop"— stops the garbage collector.
"restart"— restarts the garbage collector.
"count"— returns the total memory in use by Lua (in kilobytes).
"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
trueif the step finished a collection cycle.
argas the new value for the pause of the collector. Returns the previous value for pause.
argas the new value for the step multiplier of the collector. Returns the previous value for step.
Any. Arguments that are directly related to the value you chose for
opt. Many options do not need arguments to be passed.