[IPhone] How to Use leak to check memory leakage

Source: Internet
Author: User

Introduction
In iPhone program development, memory leakage (Memory leakage) is a very prone situation because the iPhone must manage its own memory.
Nowadays, developers are mostly used to it. . Net, Java, and other development languages with a garbage collection mechanism. Therefore, you may not be used to releasing the internal storage.

Background
I have been using xcode for iPhone development for three and a half months for the first time. During this time, I have read many articles on how to find out memory leaks. However, due to the lack of basic concepts, I have gone a long way.
In iPhone development, using nslog to print retaincount directly on the console is also a method to view the internal memory leakage. However, xcode provides a more convenient leak tool for developers.
Because of its poor concept, it took a lot of time to detour when we first began to use the leak,
Therefore, write down your own experience and hope to help more developers.
How to use leak
 

 

1. As shown in, in the xcode tool column, run => "Run with perfromance tool => leak
2. Then the leak will start

3. At the same time, I will annotate [m_images release]

4. Let's take a look at the execution results!

5. this is a game project I am currently developing. Because an object will be dynamically generated or removed from the screen as the game progresses, it is in the green frame, we can see that the memory leakage does not increase in segments.
6. The list below tells us that an array is not released in cloudanimation: LoadImage.

7. Click it to display the encoding of this section.

8. Next, I will restore the annotated test code and then execute the leak again.

9. The original memory leakage is gone.
10. Some memory leaks shown in this figure are due to the fact that the music is being played and in use and will not be released. In addition, some are errors in the SDK.

 

Supplement: How to start instruments in xcode4


 

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.