Apple & iOS
AuraScore 83/100

iOS Memory Graph and Retain Cycle Diagnostic Report

Diagnose memory leaks, closure retain cycles, and heap growth in iOS targets using Instruments memory graph analysis.

Use this template when profiling iOS applications experiencing unbounded memory growth, OOM crashes, or leaked view controllers. It generates a detailed root-cause report with exact reference decoupling fixes.

Template

Role: Staff iOS Systems and Performance Optimization Engineer

Context

  • Target Bundle: {{target_app_bundle}}
  • Profiling Environment: {{profiling_environment}}
  • Instruments Leak & Allocation Findings: {{instruments_leak_trace}}
  • Suspect View Controllers and Services: {{suspect_view_hierarchy}}
  • Memory Footprint Ceiling: {{memory_ceiling_mb}}
  • User Interaction Trigger Flow: {{leak_trigger_flow}}

Task

Generate a detailed memory diagnostic report analyzing heap growth and object graph retain cycles in {{target_app_bundle}}, providing exact code-level decoupling techniques to stay under {{memory_ceiling_mb}}.

Method

  1. Decode the memory graph signatures provided in {{instruments_leak_trace}} to map unreleased object nodes.
  2. Trace parent-child reference topologies between the items in {{suspect_view_hierarchy}}.
  3. Isolate escaping closure capture lists, delegate properties missing weak qualifiers, and notification observer lifecycles.
  4. Correlate memory accumulation with navigation iterations defined in {{leak_trigger_flow}}.
  5. Compare heap allocations before and after the trigger flow against {{memory_ceiling_mb}}.
  6. Formulate precise memory decoupling fixes (e.g., weak self, unbinding Combine subscriptions, teardown hooks).
  7. Define an automated UI test protocol using XCTest memory metrics to guard against future regressions.

Constraints

  • MUST identify the exact strong reference cycle retaining instances of {{suspect_view_hierarchy}}.
  • MUST NOT recommend force-unwrapping deallocated references or unsafe unretained pointers (unowned).
  • The proposed solution MUST respect memory boundaries within {{memory_ceiling_mb}} on low-memory devices.
  • Memory measurements MUST distinguish between dirty memory, clean memory, and compressed memory.

Output format

Provide a technical diagnostic report organized as:

  1. Memory Heap & Allocation Overview
  2. Retain Cycle Graph Analysis (Visualized ASCII Reference Chain)
  3. Closure & Delegate Capture Root Causes
  4. Remediation Code Modifications
  5. Continuous Profiling & XCTest Validation Script

Self-review

  • Verify that the reference graph pinpointed in {{instruments_leak_trace}} is completely resolved.
  • Confirm the proposed lifecycle cleanups execute reliably during normal view dismissal.
  • Ensure all memory units and thresholds adhere to the specified {{memory_ceiling_mb}} limit.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-apple
software-engineering-debugging
ios-performance
instruments
memory-leaks