IOS Project Memory Optimization

Source: Internet
Author: User

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 ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.