When writing iOS programs in non-ARC mode, the program memory leakage is inevitable. In the future, we will generally optimize the memory. You can use two common memory optimization methods.
1. Analyze: Static Analysis of Memory leakage. Click "Product"-> "Analyze" in the Xcode menu bar. After compilation, the code that may cause memory leakage in the project will be marked, in this way, we can modify the code to optimize the memory.
2. Use the built-in Xcode tool Leaks to dynamically detect memory Leaks. The general steps are as follows.
1> click "Product"-> "Profile" (1-1) in the Xcode menu bar. The instruments window 1-2 is displayed.
Figure 1-1
Figure 1-2
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + forward/forward + 87 LLiz + forward/bPM1tC/ydLUttTK1rv6yc/forward + CjxwPiAgICA8aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20140309/20140309090825245.jpg" alt = "\">
Figure 1-3
3> click Leaks circled in red in Figure 1-3, select the Call Tree option, and then select the "Invert Call Tree" and "Hide System Libraries" options. The page 1-4 is displayed, in this way, we can see the code in which method of the class causes memory leakage.
Figure 1-4
3> double-click the class name in 1-4 to display the code 1-5 that causes memory leakage in this method. Then we can optimize the code and memory accordingly.
Figure 1-5
When using Leaks here, we didn't specifically introduce some other Leaks settings and skills. You can try it yourself ....