Skip to content
Saiko

getgc

Returns every function currently tracked by the garbage collector, optionally including tables. Prefer filtergc when you know what you are looking for.

Signature

luau
getgc(includeTables: boolean?): { function | table }

Parameters

includeTablesboolean?

Include tables in the result. Defaults to false.

Returns

{ any }

Example

luau
local functions = 0
for _, value in getgc() do
    if type(value) == "function" then
        functions += 1
    end
end
print(functions, "functions are alive")

local withTables = getgc(true)
print(#withTables, "objects including tables")