Garry's Mod Wiki

Garry's Mod Wiki

  any collectgarbage( string action = "collect", number arg )

Description

Executes the specified action on the garbage collector.

Arguments

1 string action = "collect"
The action to run.

Valid actions are collect, stop, restart, count, step, setpause, setstepmul and isrunning.

isrunning is only available on the x86-64 versions, because of the difference in the LuaJIT version. See here
2 number arg
The argument of the specified action, only applicable for step, setpause and setstepmul.

Returns

1 any
If the action is count this is the number of kilobytes of memory used by Lua. If the action is step this is true if a garbage collection cycle was finished.

If the action is setpause this is the previous value for the GC's pause. If the action is setstepmul this is the previous value for the GC's step.

Example

The current floored dynamic memory usage of Lua, in kilobytes.

print( collectgarbage( "count" ) )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...