Encounter this similar [xx retain]: message sent to deallocated instance, the problem.
Using the method (Command + Shift + B) to analyze the memory leaks is no longer sufficient.
Using instruments's leaks tool to detect memory leaks during app runs can save you a lot of development costs.
The steps are as follows:
Or
The shortcut key (Command + Control + I) directly brings up the instruments tool, such as (inside the red box):
After selection, the display interface is as follows:
The above is the preparatory work, the next start debugging.
1. Select Xcode and use the shortcut key (Command + R) to keep the simulator running;
2. Select Xcode, shortcut key (Command + Control + I), let leaks in the running state;
3.leaks is dynamic monitoring, we need to manually operate the app while observing leaks changes;
Where a red Cross or red pillar appears, that is the location of the memory leak detected;
Click on the top left corner of the second button (in the Circle box), you can pause detection, you can continue to detect, there are multiple leaks, one-time processing;
4. Select the ① arrow Leaks, then select the ② arrow, select the 3 location call Tree, and then modify the 4 position settings
5. Select a row to jump to the problem code.
IOS uses instruments's leaks tool to find the exact location of the memory leak