iOhYes Retired


A podcast by iOS developers for iOS developers, delivering news, tips, and rants for professional iOS/Mac developers, with something for enterprise and indie developers alike.

Hosted by Darryl Thomas and John Sextro.

← Previous Episode   |   Next Episode →

115: Do the Weak-Strong Dance

July 27, 2016 at 11:30AM • 56 minutes • Wiki Entry

Discussion - Allocations and Leaks instruments

  • Extraordinarily hard to spot
  • Tough to find offending code without help from tools

  • Unbounded Memory Growth (memory growth without a chance to collect (deallocate) memory

  • True Leaks (retain cycles)

  • Allocations

    • Generation Analysis
    • Tracks allocations still resident when the generation is marked
        - As you do multiple generations you will see only the new allocations since the last generations
    • Simulate Memory Warning (did it help, do you have anything observing for this?)
    • I have unbounded memory growth, now what?
        - Look for the biggest offenders (sorting)
        - Drill into the code and look for ways to release unnecessary allocations
    • Good ‘ol fashion memory management
    • If you’re intentionally holding onto objects, consider implementing an observer for UIApplicationDidReceiveMemoryWarningNotification to release them
  • Leaks / Retain Cycles aka. Strong Reference Cycles

    • Persistent vs. Transient
    • Static Code Analyis
    • Narrow list to your code
    • Use / Observe (detective work)
    • “You’re in the ballpark” now what?
      • Reference counting
      • Weak and Unowned
        • Closure example with capture list; weak and unowned
      • Apple says, “Use a weak reference whenever it is valid for that reference to become nil at some point during its lifetime. Use an unowned reference when you know that the reference will never be nil once it has been set during initialization.”



  • Visual Debugging with Xcode WWDC 2016 Session 410 demonstrates the use of the new Memory Graph Debugger starting at about 24 minutes in


Show Notes & Links Presented by CacheFly

Tweet Shoutouts