Capture / compare GC snapshots
compare-gc-snapshotsCapture a GC baseline, run an in-game action, then diff against it to reveal newly allocated and freed functions, pinpointing leaks and behavior changes.
Instructions
Take a census of the garbage collector (getgc) and diff it over time to find what was allocated or freed between two points - a leak-hunting / behaviour-attribution tool. Workflow: call with action='capture' (a baseline), perform some action in-game (open a menu, fire a remote, etc.), then call with action='compare' (same snapshotName) to see what changed. Snapshots are stored CLIENT-SIDE in getgenv().__mcp_gc_snapshots[name], so they live in the target game and are naturally isolated per game / per session. capture returns: { action='capture', name, ts, counts={ function, table, thread, total }, fnSampled, truncated }. compare returns: { action='compare', name, baselineTs, nowTs, countDeltas={ function, table, thread, total }, newFunctions=[..pointers..], newFunctionCount, freedApprox (functions no longer present), sampledOnly, truncated }. Caps: at most 200000 GC objects are walked per pass and at most 4000 function pointers are remembered; results note when truncation occurred, so treat large freed/new counts near the cap as approximate. Signature: { action: "capture" | "compare", snapshotName: any?, threadContext: number? }. Phase: verify; cost=medium; idempotency=read-only. Requires: active-client. Capabilities: getgc. Produces: structured-observation. Safety: read-only. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 'capture' stores a baseline census of the GC under snapshotName. 'compare' diffs the current GC against the previously stored snapshot of that name and reports new/freed functions and per-type count deltas. | |
| snapshotName | No | Name/slot for the snapshot (default 'default'). Use distinct names to keep several independent baselines around at once. | default |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |