Environment

getgc

Returns objects currently tracked by the Luau garbage collector.

Syntax

getgc(includeTables?: boolean): table
Aliases get_gc_objects

Arguments

NameTypeDescription
includeTables?booleanWhen true, table values are included in garbage collector results.

Returns

NameTypeDescription
objectstableArray table of objects returned by the loader or garbage collector.

Description

Returns objects currently tracked by the Luau garbage collector.

Call it with 1 parameter(s): includeTables. The argument table explains which values are required and which ones only refine the behavior.

It returns objects (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getgc(true)
print(result)