Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Instruments: Leaks by Trevor Brown

Instruments: Leaks by Trevor Brown

Trevor discusses using the leaks tool in Instruments from CocoaHeads September in Durham

F13b7ea691e49d2cb953e10317f21976?s=128

Triangle Cocoa

September 27, 2012
Tweet

Transcript

  1. INSTRUMENTS: LEAKS Trevor Brown Triangle CocoaHeads September 2012

  2. What are leaks? How can we detect them? How can

    we prevent them? Q&A Resources
  3. Memory that... has been consumed (allocated), is no longer needed,

    but cannot be returned to the OS for reuse or accessed by the program that allocated it. Is there a problem with that? Waste of resources Slowdown (unresponsive) Unexpected shutdown by OS WHAT ARE LEAKS? (and why they’re bad)
  4. HOW CAN WE DETECT LEAKS? Static Analyzer (Xcode) Instruments Code

    review
  5. Launch your app with the profiler

  6. None
  7. None
  8. None
  9. None
  10. None
  11. Random audience member: “Thanks for the total waste of time,

    Trevor. I use ARC. Like, all the time. Wow... Um, beer, anyone?”
  12. RETAIN CYCLE

  13. Object A Object B RETAIN CYCLE

  14. None
  15. LEAK PREVENTION Use ARC (convert) Avoid retain cycles (no strong-strong

    relationships) Handle low-memory warnings from the OS Run the static analyzer
  16. QUESTIONS?

  17. RESOURCES Performing static code analysis Instruments User Guide ARC transition

    notes
  18. THANK YOU!