WoW:API collectgarbage: Difference between revisions
Jump to navigation
Jump to search
(Added "count" as a parameter, found in mod "!!Warmup") |
m (Move page script moved page API collectgarbage to API collectgarbage without leaving a redirect) |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{wowlua}} | ||
Control the garbage collector and query it for information. As of WoW 2.0, this is the same as the standard collectgarbage() in Lua, but prior to that it was quite different. | |||
collectgarbage([opt [, arg]]) | |||
collectgarbage( | |||
== Parameters == | == Parameters == | ||
=== Arguments === | === Arguments === | ||
:( | :([opt [, arg]]) | ||
:; | :;opt | ||
:: String - This function is a generic interface to the garbage collector. It performs different functions according to its first argument: | |||
: | * "stop": stops the garbage collector. | ||
* "restart": restarts the garbage collector. | |||
* "collect": performs a full garbage-collection cycle. This is the default action if '''opt''' is not specified. | |||
* "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 §2.10). | |||
* "setstepmul": sets arg/100 as the new value for the step multiplier of the collector (see §2.10). | |||
== Example == | == Example == | ||
collectgarbage() -- Force garbage collection | collectgarbage("collect") -- Force garbage collection | ||
collectgarbage("count") -- return kilobytes of memory in use, i.e. 2048 for 2 megabytes | collectgarbage("count") -- return kilobytes of memory in use, i.e. 2048 for 2 megabytes | ||
__NOTOC__ | __NOTOC__ | ||
Latest revision as of 04:45, 15 August 2023
← WoW Lua
Control the garbage collector and query it for information. As of WoW 2.0, this is the same as the standard collectgarbage() in Lua, but prior to that it was quite different.
collectgarbage([opt [, arg]])
Parameters
Arguments
- ([opt [, arg]])
- opt
- String - This function is a generic interface to the garbage collector. It performs different functions according to its first argument:
- "stop": stops the garbage collector.
* "restart": restarts the garbage collector. * "collect": performs a full garbage-collection cycle. This is the default action if opt is not specified. * "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 §2.10). * "setstepmul": sets arg/100 as the new value for the step multiplier of the collector (see §2.10).
Example
collectgarbage("collect") -- Force garbage collection
collectgarbage("count") -- return kilobytes of memory in use, i.e. 2048 for 2 megabytes