# Sample: finding a memory leak in a .NET dump with an AI agent

LeakDemo caches every response in a static dictionary and never removes an entry.

    ./collect.sh              # two gcdumps, a counters timeline, and artifacts/leak.dmp
    ./run-in-docker.sh        # same, inside a Linux container (use this on macOS)

Then let the agent investigate:

    dotnet-dump analyze artifacts/leak.dmp -c "dumpheap -stat" -c "exit"
    dotnet-dump analyze artifacts/leak.dmp -c "gcroot <address>" -c "exit"
    diff artifacts/heap-t1.txt artifacts/heap-t2.txt

dumpheap -stat is sorted by total size ascending: the interesting lines are the last ones. The two gcdump
reports are what proves the heap is growing; a single dump never can.

.claude/skills/analyzing-dotnet-dumps/SKILL.md is the skill the agent uses. Claude Code and GitHub Copilot read
it from that path as is; for Codex, move the analyzing-dotnet-dumps folder to .agents/skills/.

Prerequisites: .NET 10 SDK, and the diagnostic tools:

    dotnet tool install --global dotnet-dump
    dotnet tool install --global dotnet-gcdump
    dotnet tool install --global dotnet-counters
