IOS-xcode Memory leakage check static/dynamic

Source: Internet
Author: User

Static:

In Project-setting, find the "run static analyzer" key and change the value to "yes". In this way, xcode can automatically check for Memory leakage during encoding.

Dynamic:

Xcode 4.2 was found for half a day before where instruments was found: product-> Profile

Exc_bad_access error. I usually suggest:

1. Set the nszombieenabled parameter in the executable options, which sometimes helps narrow down the problem scope;

2. Run Apple's memory detection tool, suchLeaksTo find memory problems;

3. Set a breakpoint and run the code in one step until you find the location that caused the crash;

4. comment out the code until it does not crash, and then look up the error from the back;

Now let's start the experiment from the first one.

    The nszombieenabled option has no way to crash, so you can discard the resistance.


 When you use an object that has been destroyed, nszombieenabled will mark a warning, so nszombieenabled is just a flag. This is a good start, because most crashes are caused by the use of destroyed objects.

Follow these steps:

Click OK to re-run the app and crash the program at will.Check the consolelog and you will see the following information:

2011-02-0312:07:44. 778 xxxx* **-[XXXXX:]: Message sent to deallocated instance... 2. the simplest method for Memory leakage is: (shortcut key: Command + Shift + B) you will see, for example, how to modify, and slowly follow the prompts to change it step by step. Unfortunately, you cannot identify all problems by using the above methods. We also need to use a powerful automated tool to help you check whether the program has memory leakage-The leaks instrument. The next step is to activate leaks.Instrument tool. For example, select leaks and click profile. The following attempt is displayed. Click Stop (the red one) and set the debugging parameters: (select leaks, select call tree, select the three check boxes as shown in. Then click (record) to restart. The light red one indicates Memory leakage. The following two different functions indicate Memory leakage,Double-click the name of a function, which will take you directly to the line of code with Memory leakage. This can give you a good error location prompt. If you view the code and think about it, you should be able to locate the problem and solve it.

So why don't you look at the code and see if you can locate the problem and fix it? Once you make the modification, you can run leaks without error prompts. If it passes, it means you have finished

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.