> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# filtergc

> Searches live garbage-collected tables or functions that match the supplied filters. filterType must be "table" or "function". options must be a table.

<div className="real-function-page">
  ```lua theme={null}
  filtergc(filterType: string, options: table, returnOne?: boolean): table | function | nil
  ```

  ## Arguments

  <ParamField path={"filterType"} type={"string"} required>
    GC object type to search. The value is lowercased and must be "table" or "function".
  </ParamField>

  <ParamField path={"options"} type={"table"} required>
    Filter table. Function searches read Name, Hash, StartLine, IgnoreExecutor, IgnoreSyn, Environment, Constants, and Upvalues. Table searches read Metatable, Keys, Values, and KeyValuePairs.
  </ParamField>

  <ParamField path={"returnOne"} type={"boolean"}>
    Optional optional boolean handling flag. When true, returns the first matching object or nil instead of an array table.
  </ParamField>

  ## Returns

  <ResponseField name={"result"} type={"table | function | nil"}>
    When returnOne is false or omitted, an array table of matches. When returnOne is true, the first matching table/function object or nil.
  </ResponseField>

  ## Example

  Find GC tables by key filters without relying on result order.

  ```lua theme={null}
  local marker = {
      RealDocsMarker = true,
  }

  local matches = filtergc("table", {
      Keys = { "RealDocsMarker" },
  })

  for _, value in ipairs(matches) do
      if value == marker then
          print("found marker")
          break
      end
  end

  local first = filtergc("table", {
      Keys = { "RealDocsMarker" },
  }, true)

  print(first ~= nil)
  ```
</div>
