Skip to main content
Glama
carloshpdoc

memorydetective

Count instances by class

countAlive

Count alive instances per class in a .memgraph leak file. Omit class name to see top N most-leaked classes. Confirm if a fix actually reduced instance counts.

Instructions

[mg.memory] Count how many times each class appears in a .memgraph's leaked nodes. Provide className (substring) for a single number, or omit it to get the top N most-leaked classes. Use this to confirm whether a fix actually reduced instance counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to a `.memgraph` file.
classNameNoOptional class name (substring). When provided, only that class's count is returned. When omitted, all class counts are returned.
topNNoWhen `className` is omitted, return the top N most-leaked classes (default 20).
includeReferenceTreeNov1.12+. When true, also parse `leaks --referenceTree --groupByType --noContent` output and surface heap-wide instance counts alongside the cycle-side counts. Required to find classes on memgraphs where `leakCount: 0` and the abandoned-memory shape is what's interesting (e.g. orphaned KVO observers reachable from the global registry). Adds a second `leaks` invocation, run in parallel. Default false preserves v1.11 behavior.
sortByNov1.14+. Ranks the topN by either instance count (default, preserves v1.13 behavior) or total bytes (FLEX's 'Size' sort). totalBytes is `count * instanceSizeBytes` and is the right rank for 'where is my memory going?' investigations vs 'how many instances are alive?'. Per-class instanceSizeBytes + totalBytes are returned regardless of sort key.count
excludeFrameworkNoiseNov1.17 B-10. When `includeReferenceTree: true`, populates `actionableCounts[]` with the framework-noise classes filtered out (NSMutableDictionary, CFString, __DATA __bss, dispatch_queue_t, etc.). Set false to disable the filter and surface the raw counts only via `counts[]`. The curated noise list is calibrated for abandoned-memory investigations; combine with `additionalNoisePatterns` / `unsuppressClassPatterns` to tune.
additionalNoisePatternsNov1.17 B-10. Extra regex patterns (one per string) added to the noise filter. Useful when your app's noise classes are not in the curated list (e.g. third-party SDK collection storage that scales with app activity). Patterns are matched case-sensitively against the class name.
unsuppressClassPatternsNov1.17 B-10. Regex patterns that override the noise filter. Use when the default filter false-positives an actionable class (e.g. your app's `NSMutableDictionary` subclass is the actual leak site, or you want CFString back on the actionable list for a string-budget investigation).
noiseAuditModeNov1.17 B-10. When true, returns an extra `noiseAudit[]` field listing each class that was filtered out, with the matching reason ('default-list', 'additional-pattern', or 'kept-by-unsuppress'). Lets the caller verify the filter is calibrated for their app before trusting `actionableCounts[]`.
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are absent, so the description must carry full behavioral disclosure. It only states 'count instances' and mentions parameter behavior in passing but does not explain that the tool is read-only, return format, side effects, or permissions. The detailed versioning notes are in the schema, not the description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences: first defines purpose, second covers usage modes and a concrete use case. Concise and front-loaded with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite high schema coverage, the description omits contextual details like output structure, error scenarios, or deeper explanation of 'leaked nodes'. For a tool with 9 parameters in a complex domain, more context is needed beyond the schema descriptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description references className and topN but adds little beyond the schema. No contradiction with schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool counts class appearances in leaked nodes of a .memgraph file, with specific modes for single class or top N. It includes a use case ('confirm whether a fix actually reduced instance counts') and distinguishes from siblings by focusing on class counts in leaked memory.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit usage guidance: provide className for a single count or omit for top N, and use to verify fix effectiveness. However, it does not discuss alternatives or when not to use this tool, limiting full guideline completeness.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/carloshpdoc/memorydetective'

If you have feedback or need assistance with the MCP directory API, please join our Discord server