gcroot

gcroot is a command for Claude Code from frankbolero/dotnet-dump-mcp. It costs 0 tokens per session (362 once invoked), scanned A, original, MIT.

A command that finds the references keeping a particular object alive in the .NET managed heap. Garbage-collection roots are runtime references, such as live variables or handles, from which objects remain reachable.

In plain words
What is it for?
Use it with an object address to find paths from garbage-collection roots to that object during memory-leak investigations.
Why use it?
It helps explain why an object that should be gone is still using memory. The search may be truncated on very large heaps, so a reported lack of roots can be inaccurate in that case.

Command for Claude Code

Written for Claude Code: a Claude Code command (commands/*.md).

Not installable on its own: it reads a path above its own folder, which only exists inside its repository. The line is ~2M objects this can be wrong. See [GCROOT_TRUNCATION.md](../GCROOT_TRUNCATION.md); the fix makes.

Install

Getting it into your agent

There is no command for this one: it runs only inside a plugin, and the catalogue could not identify which plugin ships it. The source is linked below.

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gcroot

README.md
[![agentmods](https://agentmods.dev/badge/commands/frankbolero/dotnet-dump-mcp/gcroot.svg)](https://agentmods.dev/commands/frankbolero/dotnet-dump-mcp/gcroot)
Your own site
<a href="https://agentmods.dev/commands/frankbolero/dotnet-dump-mcp/gcroot"><img src="https://agentmods.dev/badge/commands/frankbolero/dotnet-dump-mcp/gcroot.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 362 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00362
Opus 5 $0.00000 $0.00181
Sonnet 5 $0.00000 $0.00072
Haiku 4.5 $0.00000 $0.00036

Measured 6d ago against content hash c5d8dbbcdabd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

gcroot scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/gcroot.md · 41 lines

What it actually says

gcroot

Displays information about references (or roots) to a specified object. It helps in identifying what is keeping an object alive in the managed heap.

Known defect: the search is bounded at 2,000,000 visited nodes and a truncated search is currently reported as "no GC root path found" — i.e. as if the object were unrooted. On heaps above ~2M objects this can be wrong. See GCROOT_TRUNCATION.md; the fix makes the bound settable (--max-nodes, 0 = unlimited) and always reports truncation.

Usage

gcroot <address>

Example

> gcroot 000001D0F90F34E0

ClrMD Implementation

Use GCRoot helper class or manually walk the heap references. Modern ClrMD provides EnumerateGCRoots.

using Microsoft.Diagnostics.Runtime;

// ... (Setup DataTarget and ClrRuntime)
ulong targetAddress = 0x12345678;

// Note: GCRooting can be complex. 
// You often need to build a reference graph or use the GCRoot class if available in your version.
// A simple approach is finding roots pointing to it:
foreach (ClrRoot root in runtime.Heap.EnumerateGCRoots())
{
    if (root.Object == targetAddress) 
    {
       Console.WriteLine($"Root found: {root.Kind} at {root.Address:X}");
    }
}

Link: GCRoot.cs

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 41 lines · 0 tokens per session scan A c5d8dbbcdabd

Subscribe to this mod's changes

gcroot is a command published in the GitHub repository frankbolero/dotnet-dump-mcp (12 stars, last pushed 11d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 362 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.