How memory leaks are detected:
First, static detection method
1) Manual static detection
Using the Xcode analysis feature, Product->analyze
2) automatic static detection
In the project's build setting, set analyze During ' build ' to Yes
Second, dynamic detection method
1) Instrument Tool detection Leaks
2) Third-party memory detection tools, such as Mleaksfinder
Third, the destruction method Dealloc printing
In general, when creating a project, I will enable analyze During ' build ' in build settings, which will be automatically analyzed at compile time. In this case, after writing a short piece of code, you immediately know if there is a memory leak or other bug problem, and you can fix bugs. In the run process, if exc_bad_access appears, enable nszombieenabled, see if an exception occurs, the console can print more prompt information. If you want to see if there is a memory leak at run time, use the Instrument leak tool. But some memory leaks are hard to check out, sometimes only by manually overwriting the Dealloc method to see if it eventually has no call.
How IOS memory leaks are detected