简体   繁体   中英

Manual Memory Management VS ARC

I'm reading a book on Objective C, and I was wondering about 2 things:

1.Should I take the time currently to read a whole chapter on memory management since we mostly use ARC?(only asking this question to make sure im managing time properly)

2.If you are doing a really good job on manual management, can you get to better performance than using ARC? (like that your app will work faster)

tnx

  1. You should at least familiarize yourself with the basic concepts of the manual memory management, because ARC uses it under the hood. You need to learn at least about three things: retain , release , and autorelease . This will help you understand discussions about ARC's inner working.
  2. ARC is mostly a compiler trick (with some support from the runtime). You can write less code, but you cannot get better performance from it. Essentially, ARC lets you deal with memory management declaratively , while the manual management uses imperative style. However, both systems call the same methods from the runtime.

1、Of course you should.ARC is based on the same memory management,just let the compiler do the same work.If you want to master a kind of technology,try to know how does it work is a faster way.

2、Actually,they do the same performance.Just let the compiler do what did you do before.For when you retain an object(which is a property) in the class, we always release in the dealloc.you alloc an object in a method,assign to local pointer,it will be release when the stack memory of this method clean up;if you retain it in the method to the method's local variable you release it in the same place.Then you will be find they are all predictable.why not let the machine do it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM