getgc Synchronous

  • get_gc_objects

Take a snapshot of live garbage-collected values in the current VM. It is useful for inspection tools that need to locate closures, userdata, or optionally tables.

Syntax
Luau
getgc(includeTables: any?) -> {Function | userdata | Table}

Parameters

Function parameters
ParameterTypeDescription
includeTablesany?Optional truthy value. By default tables are left out.

Returns

{Function | userdata | Table}

An array of live functions and userdata, plus tables when includeTables is truthy.

Usage notes

The snapshot may be large and can change between calls. Enumeration order is not stable.

Example

Example
Luau
local values = getgc(false)
print("Visible GC values:", #values)
Kawaii documentation