Find all GC references to a specific table (reverse ownership scan)
find-table-referencesFind which tables and closures reference a target Luau table by scanning GC objects, so you can identify owners, captured upvalues, or why it is not collected.
Instructions
Answer 'who holds this table alive / who can reach it?' Resolve a Luau expression to a target TABLE, then walk the entire GC and record every OTHER object that references it: (1) for each GC TABLE, pcall-iterate pairs() and if any VALUE is the target, record { container, via='value', key } (the surrounding key text); (2) for each Lua CLOSURE, scan its upvalues (getupvalues, guarded) and if any UPVALUE is the target, record { container, via='upvalue', key } where container is the function's source:line (via debug.info / getinfo). The target table itself is skipped so it never lists itself. This is the inverse of the look-down tools (read-path-value, dump-table): use it to find the owner of a shared state/config table, to discover which closures captured it (so you can hook or inspect them), or to understand why a table is not being collected. Every access is pcall-guarded so locked objects never abort the scan; GC objects examined are capped by maxScan and results by limit, with a 'truncated' flag. Requires getgc; upvalue scanning additionally needs getupvalues (type-guarded — skipped if absent). Returns { target, referenceCount, scannedObjects, truncated, references } or { error }. Signature: { tableExpr: string, limit: any?, maxScan: any?, threadContext: number? }. Phase: observe; cost=medium; idempotency=read-only. Requires: active-client. Produces: bounded-candidates. Safety: read-only. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of references to return (default 100). Hitting this sets truncated=true. | |
| maxScan | No | Maximum number of GC objects to examine before stopping (default 40000). Hitting this sets truncated=true. Raise for a deeper sweep at the cost of time; lower if scans are slow. | |
| tableExpr | Yes | Luau expression resolving to the target TABLE whose references you want to find, e.g. 'getgenv().PlayerData', 'require(game.ReplicatedStorage.Config)', '_G.Settings', or any table reference from a prior scan. Evaluated as `return <tableExpr>` and must resolve to a table. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |