IOS Instruments Memory detection using

Source: Internet
Author: User
Tags configuration settings

Instruments can help us understand several aspects of how the application uses memory:
    • 全局内存使用情况(Overall Memory Use): Monitor the application's memory usage from a global perspective to capture unexpected or significant memory growth.
    • 内存泄露(Leaked memory): Memory that is not referenced by your program and cannot be used or freed.
    • 废弃内存(Abandoned memory): It is referenced by your program, but there is no memory for eggs.
    • 僵尸对象(Zombies): A Zombie object means that the corresponding memory has been freed and will no longer be used, but your program still has a reference to it somewhere. There is a nszombie mechanism in IOS, which is a mechanism designed for the purpose of memory debugging. In this mechanism, when you nszombieenabled to YES, when a corresponding reference count is reduced to 0 o'clock, the object will not be released, and when the object receives any more messages, it will record a warning instead of a direct crash to facilitate our program debugging.

Here we describe the process of looking for a memory leak:

1, the same as "CPU occupancy performance test", first in Xcode to the current project execution profile (Command-i), and in the Open dialog box to select Leaks This template:

2. After entering Instruments, select the right device and application.

3, click the red button to run the application, we can see the following interface:

4 Invert Call Tree . Tick and Hide System Libraries or other options in display Settings to filter the displayed data.

5, in the Navigation bar filter box, we can enter keywords to filter the data.

6, in the actual use, we enter a page and then exit, found that the relevant memory allocation is not emptied, this time a memory leak occurs. We look at the more detailed invocation information and trace the location of the code that might have caused the memory leak:

7, we can also use Activity Monitor , Allocations and Zombies other templates to do targeted memory monitoring. in the development I usually use the instrument tool with Xcode is enough, its shortcut key is (Commend+i), is a self-contained can be used to analyze the performance of the application,There are three features that are often used in development, 1,leaks can detect memory leaks, using it can see a global memory usage, you can also see if there is a memory leak, whether there is a wild pointer; 2, is can use Core Animation + Time Profiler to evaluate the graphics performance, can be very intuitive to see the performance of the interface is good. 3. Time Profiler after the application has started running. We can see the different threads and how long the method calls take, so that we can evaluate the bottleneck of CPU performance and find the direction of optimization. but there are 2 points to note when using Xcode as a tool:1. Need to use the real machine. because the phone's cpu,gpu and simulator are different, the MAC CPU is faster than the mobile phone, and the simulator to use the CPU to simulate the phone's GPU, this simulator is not comparable to the mobile phone. 2. The application runs must publish the configuration instead of the Debug configuration. Because when packaged, the compiler automatically optimizes, such as removing debug symbols or removing and re-organizing code, and introducing the "Watch dog" [watchdog] mechanism, In different scenarios,the watchdog monitors the performance of the app, but watch dog is disabled under Xcode's configuration settings.

IOS Instruments Memory detection using

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.