SuperAPI AI Directory

memorydetective

iOS memory leak and performance investigation: reads .memgraph and .trace files, classifies retain cycles against known patterns and suggests Swift fixes.

Open website

About this tool

memorydetective is an MCP server for iOS leak investigation and performance investigation, driven via the command line or a chat window, officially described as "diagnose iOS reference cycles and performance regressions from a chat window without Xcode".

[Purpose] Reads .memgraph files captured by Xcode (or by memorydetective itself on the simulator), finds ROOT CYCLEs, classifies them based on known SwiftUI/Combine patterns, and gives a one-line fix suggestion, all of which can be done in a script or in chat. It natively supports the MCP protocol and can be connected to MCP clients such as Claude Code, Claude Desktop, Cursor, and Cline, with an agent driving the complete "investigate → classify → suggest fix" loop.

[Main capabilities] The official description states that it has 28 MCP tools, a reference-cycle classifier with 34 patterns (with Swift fixTemplate code snippets), compareTracesByPattern for CI gating, and a SourceKit-LSP source bridge. It can read .memgraph and .trace files, macOS only. According to the changelog, v1.18 adds analyzeMetricKitPayload (the 42nd MCP tool), which can ingest Apple MetricKit .mxdiagnostic JSON payloads from real-device TestFlight / App Store builds, output crash clustering (by exception type/binary/top frame), hang hotspots (with support for localized duration parsing, such as "5.4 sec" / "20秒"), CPU and disk anomalies, and provide cross-toolchain hints. v1.17 made reliability fixes (environment variable truth-value parsing, verifyFix whitelist matching modes exact/substring/regex, etc.). v1.16 adds recordViaInstrumentsApp, wrapping the Instruments.app graphical workflow. v1.15 adds analyzeMemoryFootprint, analyzeEnergyImpact, and analyzeLeakTimeline. Earlier versions successively added summarizeTrace, inspectTrace, diffMemgraphs, mainThreadViolations, etc.

[Usage] As an MCP server, the memorydetective binary communicates over stdio, and any MCP-compatible client can be pointed at it; the official documentation provides an example of what to add to a Claude Code client configuration, as well as how to use it directly from the command line (see the official repository documentation for the specific configuration and commands). It also supports injection into clients such as Claude Desktop, Cursor, and Cline.

[Typical workflows] The official examples show a self-contained verification loop for diagnosing a leak from an exported memgraph, using diffMemgraphs to verify whether a fix took effect, building and reproducing (bootAndLaunchForLeakInvestigation + replayScenario + captureScenarioState), as well as real-device performance sampling (listTraceDevices → recordTimeProfile → analyzeHangs) and MetricKit production crash analysis, ultimately able to combine with the SourceKit-LSP source bridge to pinpoint the specific file and line number and give fix suggestions.

[Limitations and known issues] The official documentation clearly states: Memory Graph capture is available on Mac apps and the iOS simulator; physical iOS devices still require Xcode; hang analysis can parse sample-level Time Profiles when xctrace can symbolicate, and when it cannot symbolicate it returns a structured workspace hint (the SIGSEGV from xctrace on heavily unsymbolicated traces is an Apple-side limitation). On macOS 26.x, Apple has a task_for_pid kernel regression that blocks leaks --outputGraph, heap, and xctrace --template Allocations operations against iOS simulator processes; the official recommendation is to switch to an iOS 18 simulator runtime (installable via Xcode > Settings > Platforms > +iOS 18.x), and MEMORYDETECTIVE_SUPPRESS_PLATFORM_ADV can be usedISORY=1 silent hint. On macOS 26.x, xctrace record is likewise broken for simulator targets; the official workarounds given are to use recordViaInstrumentsApp, to record on an older macOS host running Xcode 26.0, or to record against a physical device. The MetricKit payload analysis in v1.18 does not yet provide symbolized frames (it outputs only raw binaryUUID + offset; dSYM lookup is a separate tool and will be provided in a future version).

[Pricing and Charges] Official materials do not provide pricing or charge information.