Memory Leak Diagnosis Skill
Installation
SKILL.md
Memory Leak Diagnosis Skill
This skill provides expertise in identifying, diagnosing, and fixing memory leaks and retain cycles in Swift applications. It covers Instruments usage, ARC concepts, and memory management best practices for iOS development.
Best Practices
-
Understand ARC: Automatic Reference Counting manages memory automatically, but cycles can still occur.
-
Use Weak References: Break retain cycles by using
weakorunownedreferences in closures and delegates. -
Profile Regularly: Use Instruments to detect leaks early in development.
-
Avoid Strong Reference Cycles: Be aware of parent-child relationships and delegate patterns.
-
Clean Up Resources: Properly invalidate timers, cancel network requests, and remove observers.
-
Test Memory Usage: Monitor memory growth during app usage.