takeaway

Learning objective-C memory management

  • Book: Objective-C Advanced Programming: Multithreading and Memory Management for iOS and OS X
  • Advanced Memory Management Programming Guide
  • Apple official documentation: Transitioning to ARC Release Notes
  • Apple to maintain the Runtime of the open source library: opensource.apple.com/tarballs/ob…

And summarized the following articles:

  • IOS – The Cliche memory Management part 1: Reference Counting
  • IOS – The Old Story of Memory Management (2) : Starting with MRC
  • IOS – The Cliche of Memory Management (3) : ARC is here to stay
  • IOS – the old memory management (four) : memory management method source analysis
  • IOS – Memory management (5) : Tagged Pointer
  • IOS – The Old Story of Memory Management (6) : AutoRelease and @Autoreleasepool
  • IOS – The Old Story of Memory Management (7) : Hard editing 💪 💪 💪

Article outline:

The following lists some of the problems with memory management. If you are confused or have only vague answers to the following questions, this series of articles can help.

  • What are the iOS memory management schemes?
  • Talk about the memory management mechanism of iOS
  • How does the reference counting mechanism work?
  • Where are reference counts stored? Where was it stored? How about now?
  • Can we talk about ISA? What is nonpointer?
  • SideTable is a SideTable.
  • How exactly is reference counting managed? Can you talk about the implementation of the memory management approach?
  • How about MRC memory management rules?
  • When do I need to send a release message to an object under MRC? When to use AutoRelease?
  • Why not use accessor methods in initialization methods and dealloc?
  • Why do I need self = [super init] in my initialization method?
  • Can you talk a little bit about how super works?
  • ARC memory management rules?
  • Are there no retain/release methods under ARC?
  • Toll-free Bridged? Describe it in detail.
  • What are the ownership modifiers?
  • How is the weak variable set to nil after the object is destroyed, and how does the Runtime implement it?
  • How does Runtime assign the weak variable?
  • __weak is safer, so why retained __unsafe_unretained?
  • How do circular references come about? How to avoid the circular reference problem under MRC?
  • What situations in ARC can cause circular references? How to solve it?
  • Release NSAutoreleasePool using the difference between [pool release] and [pool drain].
  • @autoreleasepool How much do you know?
  • How does @autoreleasepool work?
  • When do YOU need to create @Autoreleasepool yourself?
  • When are local objects in a method released in ARC?
  • When is an AutoRelease object released in ARC?
  • Do I need to manually add @Autoreleasepool in ARC?
  • What is Tagged Pointer?
  • How to determine Tagged Pointer?

Read the note

To avoid semantic confusion, the word “release” in all articles refers to release and the word “destroy” refers to dealloc.

If you find any errors in your reading, please point them out.

Summary is not easy, point a concern!