Use instruments leaks to detect memory leaks

1. Open the tool
Xcode ->product->profile to enter the instruments tool, and then select leaks.
2. Detection
Connect to the real machine, run in instruments, select leaks
Insert picture description here

It works like this.
Insert picture description here
This green check mark means normal.
Insert picture description here
This red cross sign means there is a leak.
Insert picture description here
Then you can see the leaked method on the left side of the bottom and the call path on the right.
Insert picture description here

Double-click the method, you can locate the specific code (there is really a leak)
Insert picture description here

After the code is modified, it needs to be restarted. The above screenshot has actually been repaired, but it has not been restarted, so it will still be leaked.
Fix it at the end.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_28285625/article/details/108346192