memory-leak-diagnosis-skilllisted
Install: claude install-skill fal3/claude-skills-collection
# Swift Memory Diagnosis
Prove the lifetime bug before changing capture lists. “Memory grew,” “deinit has not run yet,” “an object is retained,” and “an allocation is leaked” describe different evidence.
## Compatibility baseline
ARC, weak references, and Xcode’s core memory tools apply across currently supported Swift/Apple-platform projects. State version requirements for the specific APIs in the inspected code:
- Structured concurrency and `Task` require Swift 5.5 and the corresponding platform concurrency runtime.
- The task example in this skill uses duration-based sleep, available with Swift 5.7-era toolchains and iOS 16 / macOS 13.
- Observation, SwiftData, Combine, and framework-specific lifetime rules depend on the app’s declared deployment targets.
- Xcode and Instruments UI labels change. Describe goals and inspected relationships, not assumed arrow colors or displayed reference-count numbers.
## Classify the symptom
| Observation | Likely category | Best first tool |
| --- | --- | --- |
| A dismissed screen remains reachable | Unwanted retention / ownership bug | Memory Graph |
| Heap grows after repeating one workflow | Persistent allocations, cache, or leak | Allocations generations |
| Leaks instrument reports unreachable blocks | Heap leak | Leaks + allocation backtrace |
| Memory falls after pressure or cache purge | Cache / transient high-water mark | Allocations + signposts |
| Process is killed under memory pressure | Excess footprint / jetsam | Orga