When writing iOS programs in non-arc mode, it is unavoidable that program memory leaks, and later we generally do memory optimization. There are two kinds of memory optimization methods that you use more commonly
1, Analyze, static analysis of memory leakage method. Very simply, click "Product", "Analyze" in the Xcode menu bar, and the code that could cause a memory leak in project engineering will be flagged, so we can have a targeted change code to optimize the memory.
2, using Xcode's own tool leaks, dynamic detection of memory leaks. The general steps are as follows.
1> in the Xcode menu bar, click "Product", "Profile" (1-1), pop-up instruments window 1-2
Figure 1-1
Figure 1-2
2> in the Instruments window click "Leaks" (1-2), General Leaks began to automatically detect the project memory leaks, in the process can be run on the mobile phone test engineering operation, the Red column appears after 1-3,leaks a memory leak.
Figure 1-3
3> Click on the red circle leaks in Figure 1-3, select the Call Tree option, and then select the "Invert Call Tree" and "Hide System Libraries" options, the 1-4 interface appears, so we see the Which of the methods in the class is causing the memory leak.
Figure 1-4
3> double-clicking the class name in 1-4 shows that the code that caused the memory leak in this method is 1-5, and then we can optimize the code and optimize the memory.
Figure 1-5
When using leaks here, there is no specific description of leaks's other settings and techniques, and the small partners can try it out on their own in the process ....
IOS---memory optimization