Count instances by class
countAliveCount 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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to a `.memgraph` file. | |
| className | No | Optional class name (substring). When provided, only that class's count is returned. When omitted, all class counts are returned. | |
| topN | No | When `className` is omitted, return the top N most-leaked classes (default 20). | |
| includeReferenceTree | No | v1.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. | |
| sortBy | No | v1.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 |
| excludeFrameworkNoise | No | v1.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. | |
| additionalNoisePatterns | No | v1.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. | |
| unsuppressClassPatterns | No | v1.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). | |
| noiseAuditMode | No | v1.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[]`. |