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

Memory Management in iOS App Development

Sumin Byeon
September 03, 2009

Memory Management in iOS App Development

Sumin Byeon

September 03, 2009
Tweet

More Decks by Sumin Byeon

Other Decks in Programming

Transcript

  1. Alloc Allocates memory for an object, and returns it with

    retain count of 1[1]. Almost equivalent to the new keyword in C+ +, Java, etc. [1] http:/ /developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html
  2. Master Theorem #1 If you allocated it, you should release

    it. If you didn’t explicitly allocate it, don’t release it.
  3. Master Theorem #2 If an object is being retained by

    something else, you may release it immediately. (e.g. [UIView addSubview:view])
  4. Master Theorem #3 Don’t you dare call dealloc. Always call

    release, and dealloc will be called when the retain count becomes zero.