IOS---memory optimization

Source: Internet
Author: User

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

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.