The reason

Recently, the APP triggered some special operations at some time, which caused the temperature of the APP to continue to rise. This problem has bothered us for a long time. Just yesterday, the girl tested successfully triggered this operation. Thus came this inquiry. First of all, we can think about the possible reasons for the hot APP. Such as CPU, memory, positioning, networking, audio and video, motion sensors (such as gyroscopes), Bluetooth, etc. Of course, this requires the use of several of these listed functions in our project.

memory

The memory leak part should say we best locate the problem.

1. For example, use Xcode’s static analysis (although it’s not very accurate).

How to quickly locate the problem

You might ask so many questions that I have to go through them one by one? Is there an easier way? Well, there is. Here’s what you’ll need :Energy Log

1, choose

6, if you can’t see the specific calls to these functions, you need to go to Xcode -Build settings-debug information Format – modify DWARF with DSYM File

7, Click on weight to rank the longest thread at the top and select it (you can also see which thread continues to grow), go to the AVIE view StackTrace to see what the longest thread is doing, and double click on one of the methods. We can see which lines of code in the actual project might be problematic.

8. In this way, we can quickly locate the specific module that affects our whole project. Of course, if you want to learn more about Instruments, you can check out my other post

Class, I have an iOS interview bonus, do you want to know about it?

Of course, some people will ask me that when the APP heats up, maybe the phone is not connected to Xcode, so if I run the APP again, maybe it will not reappear?

Record anytime, anywhere

How do we keep a log whenever and wherever we think there might be problems or things that are important? The open source log library CocoaLumberjack is our project’s important log management tool.

Logs can be printed to the Xcode console, to the MAC console program, and to files. 2. Logs can be disabled or enabled at Error, Warning, Info, Debug, Verbose, and All log levels

Support custom log formats based on DDLogFormatter and DDAbstractLogger and DDLogger custom logger

4. Package compressed log files to upload according to the logic of our project.

So we can detect users who are constantly experiencing exceptions where they are in the APP at the time, and what triggers the exception. Of course, how to detect these abnormal conditions that affect our APP?

This is a MindNode diagram of iOS quality assurance and Performance monitoring drawn by me after reading wechat books. It summarizes how many things wechat has done.

IOS quality assurance and performance monitoring

Remedy is only the last resort

1. Optimize I/O access

2. Reduce network requests

3. Delayed networking

4. Image, animation, video

5. Optimize positioning and Motion

6. Optimize notifications

.

I’ll write another article on how to do this when I have time.