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.
Luau
getgc(includeTables: any?) -> {Function | userdata | Table}Parameters
| Parameter | Type | Description |
|---|---|---|
includeTables | any? | 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
Luau
local values = getgc(false)
print("Visible GC values:", #values)