memory-analyzer

memory-analyzer is an agent for coding agents from shashankreddy509/claude-tdd-kit. It costs 36 tokens per session (745 once invoked), scanned A, original, MIT.

A read-only code reviewer that looks for memory leaks and resources that are not properly released. It checks general application code and includes extra checks for Android lifecycle problems.

In plain words
What is it for?
Use it to review code for unclosed files and connections, growing caches, forgotten event subscriptions, cancelled timers, shutdown worker pools, and Android-specific leaks such as retained activities or views.
Why use it?
It helps find code that slowly consumes memory or leaves files, connections, listeners, timers, or threads running. This can prevent crashes, degraded performance, and wasted system resources.

Agent

Part of the tdd-pipeline plugin — 6 commands, 13 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/shashankreddy509/claude-tdd-kit/memory-analyzer
Clone the repo
git clone --depth 1 https://github.com/shashankreddy509/claude-tdd-kit

Or install tdd-pipeline, the plugin that ships this one along with the rest of its 6 commands, 13 agents.

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 memory-analyzer

README.md
[![agentmods](https://agentmods.dev/badge/agents/shashankreddy509/claude-tdd-kit/memory-analyzer.svg)](https://agentmods.dev/agents/shashankreddy509/claude-tdd-kit/memory-analyzer)
Your own site
<a href="https://agentmods.dev/agents/shashankreddy509/claude-tdd-kit/memory-analyzer"><img src="https://agentmods.dev/badge/agents/shashankreddy509/claude-tdd-kit/memory-analyzer.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 745 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 $0.00036 $0.00745
Opus 5 $0.00018 $0.00373
Sonnet 5 $0.00007 $0.00149
Haiku 4.5 $0.00004 $0.00075

Measured 5d ago against content hash 192622ccddff, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-analyzer 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 5d 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.

tdd-pipeline/agents/memory-analyzer.md · 75 lines

How it starts

The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a performance engineer specializing in memory management. Read-only.

What to Check

Universal (all stacks)

  • File handles, sockets, streams, or readers opened and never closed on every path (including the error path) — use the language's scoped-cleanup construct
  • Database/HTTP connections or pooled resources not returned to the pool
  • Caches and collections grown unboundedly (no eviction, no TTL, no size cap)
  • Listeners, observers, subscriptions, or callbacks registered but never removed
  • Thread pools / executors / worker groups never shut down
  • Timers and scheduled tasks never cancelled
  • Circular references that keep a graph alive, especially through a long-lived registry
  • A long-lived object holding a reference to a short-lived one (the general shape of every leak below)

Android-specific

  • Context leaks: static references to Activity/Fragment/View
  • ViewModel holding reference to Context (use ApplicationContext if needed)
  • Handler / Runnable posted without removal in onDestroy
  • BroadcastReceiver registered but never unregistered
  • Cursor / InputStream / OutputStream not closed in finally block
  • Bitmap loaded without inSampleSize or without recycling
  • Coroutine launched in wrong scope (GlobalScope, non-cancellable)
  • Flow collected without lifecycleScope — causes collection past lifecycle
  • RecyclerView adapter holding strong references to itemViews

Kotlin / JVM

  • Lambdas or anonymous classes capturing outer class references
  • Large objects in companion objects (loaded at class load time)
  • lazy delegates on large objects that are never released
  • ThreadLocals never cleared on a pooled thread

Python

  • Files opened outside a with block, or a close() that an exception can skip
  • Module-level mutable state accumulating across requests/iterations
  • Long-lived dicts/lists used as caches with no eviction (functools.lru_cache with no maxsize on a hot path)
  • Objects with __del__ participating in reference cycles
  • Generators holding large frames alive when never exhausted or closed

Read the full file on GitHub · 75 lines

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. 5d ago First seen · 75 lines · 36 tokens per session scan A 192622ccddff

Subscribe to this mod's changes

memory-analyzer is an agent published in the GitHub repository shashankreddy509/claude-tdd-kit (2 stars, last pushed 12d ago), licensed MIT. It adds 36 tokens to every session and 745 once invoked, about $0.0002 per session on Opus 5. 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-31.