Difference between revisions of "Collectgarbage"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 7: | Line 7: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
collectgarbage(opt,arg) | collectgarbage(opt,arg) | ||
− | </ | + | </syntaxhighlight> |
It performs different functions according to its first argument, opt: | It performs different functions according to its first argument, opt: | ||
Line 27: | Line 27: | ||
collectgarbage("setstepmul",1000) | collectgarbage("setstepmul",1000) | ||
collectgarbage() | collectgarbage() | ||
− | </ | + | </syntaxhighlight> |
{{(global)}} | {{(global)}} |
Latest revision as of 14:26, 13 July 2023
Available since: Gideros 2011.6
Class: (global)
Description
This function is a generic interface to the garbage collector.
collectgarbage(opt,arg)
It performs different functions according to its first argument, opt:
- "stop": stops the garbage collector
- "restart": restarts the garbage collector
- "collect": performs a full garbage-collection cycle
- "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 as the new value for the pause of the collector. Returns the previous value for pause
- "setstepmul": sets arg as the new value for the step multiplier of the collector. Returns the previous value for step
Parameters
opt: (string) command for garbage collector mechanism
arg: (varies) additional parameters for command optional
Example
Takes over automatic garbage collection, do it in small steps. Increase/decrease the amount depending on your game
collectgarbage("setstepmul",1000)
collectgarbage()