collectgarbage()

Type Function
Library (globals)
Return value none
Revision Current Public Release (2014.2189)
Keywords garbage collection, garbage, memory, resources
Sample code none
See also

Overview

A generic interface to Lua's garbage collector. Using this function is not required because Lua has automatic garbage-collection features. More information here.

Syntax

collectgarbage( [opt [, arg]] )
opt (optional)

String. Performs garbage-collection functions differently based on this option. See Possible values for opt section for a complete listing. The default (if this argument is omitted) is: "collect"

arg (optional)

Any. Arguments that are directly related to the value you chose for opt. Many options do not need arguments to be passed.

Possible values for opt

The following is a list of accepted strings for the opt argument: