Yuari
Documentation
Docs/Script/getobjectreferences

getobjectreferences(value)

Walks the GC heap and returns tables that directly hold the given value.

Syntax

getobjectreferences(value: any) -> {table}

Parameters

ParameterTypeDescription
valueanyValue to search for. nil returns an empty table.

Returns

TypeDescription
{table}Tables whose array or hash part references the value.

Description

getobjectreferences scans every live table in the current global state, including array and hash parts, and returns the tables that reference the value by identity.

GC is paused during the walk. Each table is returned at most once, and the scan does not descend into closures or userdata.

Example

local box = { holder = { {} } }
local refs = getobjectreferences(box.holder[1])
print(table.find(refs, box.holder) ~= nil)