WoW:API collectgarbage: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Added "count" as a parameter, found in mod "!!Warmup")
No edit summary
Line 1: Line 1:
{{wowapi}}
{{wowapi}}
<center>'''collectgarbage''' ''-Documentation by [[user:Aradan|Aradan]]-''</center>
<center>'''collectgarbage''' ''-Documentation by [[user:Aradan|Aradan]], Update by [[user:CuteMiyu|CuteMiyu]]-''</center>


Sets garbage collection limit and calls the garbage collector if the Lua byte counter exceeds this limit.
Sets garbage collection limit and calls the garbage collector if the Lua byte counter exceeds this limit.


  collectgarbage({limit})
Since WoW 2.0, it change to Lua 5.1. Lua 5.1 changed collectgarbage design, and you need update your script or AddOn if you used this function.
 
  collectgarbage(opt [, arg])


== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:({limit})
:(opt [, arg])


:;limit : Number - GC limit (in KiB). If omitted, defaults to zero, forcing garbage collection.
:;opt: String - This function is a generic interface to the garbage collector. It performs different functions according to its first argument:


:;limit : "count" - will return the total kilobytes of memory used
::   * "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/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(131072) -- Set GC limit to 128 MiB
  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



Revision as of 15:58, 27 March 2007

WoW API < collectgarbage

collectgarbage -Documentation by Aradan, Update by CuteMiyu-

Sets garbage collection limit and calls the garbage collector if the Lua byte counter exceeds this limit.

Since WoW 2.0, it change to Lua 5.1. Lua 5.1 changed collectgarbage design, and you need update your script or AddOn if you used this function.

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.
* "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

Note

There is a Lua function with the exact same name but its parameters and behavior is quite different from the WoW API version.