Manual memory management VS ARC

I am reading a book about Objective-C, and I was wondering about two things:

1. Do I have to spend time reading an entire chapter on memory management, since we mainly use ARC? (just asking this question to make sure it is managing time correctly)

2. If you are doing a really good job of manual control, can you achieve more performance than with ARC? (for example, your application will run faster)

Tnx

+4
source share
2 answers
  • You should at least familiarize yourself with the basic concepts of memory management manually, because ARC uses it under the hood. You need to learn at least three things: retain , release and autorelease . This will help you understand how the internal workings of ARC work.
  • ARC is basically a compiler trick (with some support from runtime). You can write less code, but you cannot get better performance. In essence, ARC allows you to handle memory management declaratively, while manual control uses an imperative style. However, both systems use the same methods from the runtime.
+5
source

1, of course, you should .ARC is based on the same memory management, just let the compiler do the same. If you want to learn some technology, try to find out how it works, this is a faster way.

2. In fact, they perform the same performance. Let the compiler do what you did before. When you save an object (which is a property) in the class, we always release in dealloc.you allocate the object in the method, assign it to the local pointer, it will be released when clearing the stack of this method will be cleared if you save it in the method local variable of the method. you let her go in the same place. Then you will find them all predictable. Why not let the car do it?

+1
source

All Articles