Latest version addresses iOS memory leaks with Xcode6.4 and instruments, leaks debugging

Source: Internet
Author: User
<span id="Label3"></p><span style="color:rgb(51,51,51)"><span style="color:rgb(51,51,51)">                                          </span></span><span style="color:#cc0000"><span style="color:#cc0000">Analyze memory leaks</span></span><span style="color:#000099"><span style="color:#000099">recently used to memory leaks, to view the previous blog, the method is good, but the operation, the steps are not found, do not know how to Operate. So Here's a simple example</span> .</span><span style="color:#000099"><span style="color:#000099"> <span style="color:rgb(51,51,51); font-family:Verdana,Arial,sans-serif; font-size:14px; line-height:18.200000762939453px">Experimental Development environment: XCode 6.4</span><br></span></span><p style="font-family:Arial; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="font-family:Arial; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000"><span style="font-size:24px">yi, Analyze <span style="color:rgb(51,51,51); font-family:Arial; line-height:26px">(shift+command+b)</span></span></span></p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">The app isn't crash, so see if There's a memory Leak. With Xcode's analyze, you can analyze where There's a memory Leak.</p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"></p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="font-family:Verdana,Arial,sans-serif"><span style="line-height:18.200000762939453px">After analysis, you can see:</span></span></p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="font-family:Verdana,Arial,sans-serif"><span style="line-height:18.200000762939453px"><br></span></span></p></p><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="font-family:Verdana,Arial,sans-serif"><span style="line-height:18.200000762939453px">Here is a hint that alertview is not released, there is a memory leak, then we release</span></span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">[alertview <span class="s1">Release</span>];</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Further analysis, this problem solved.</p></p><p class="p1" style="font-family:Arial; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"></p></p><span style="font-size:24px"><span style="font-size:24px"> <span style="color:#cc0000">second, using the instruments leaks tool</span> <span style="color:#333333">(command + control + i)</span> </span></span>The analysis of memory leaks does not reveal all memory leaks, and some memory leaks are generated when the user is operating at Runtime. Then we need to use the Instruments. Or choose the first Instruments<span style="color:#333333; font-size:14px"><span style="color:#333333; font-size:14px">Press the above, build succeeds and jumps</span> out</span><span style="font-size:14px; color:rgb(51,51,51); font-family:Verdana,Arial,sans-serif; line-height:18.200000762939453px"><span style="font-size:14px; color:rgb(51,51,51); font-family:Verdana,Arial,sans-serif; line-height:18.200000762939453px">Instruments tools, Select the leaks option,</span></span><br><p><p></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Display the interface, then select leaks</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Select the rear interface</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">well, get ready for the job, even if it's done, start a formal Test.</p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000">The key steps</span></p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000">1.</span> <span style="color:rgb(51,51,51)">First we select Xcode to first run the simulator (command + R).</span></p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="font-family:Arial; font-size:14px; line-height:26px"><span style="color:#cc0000">2.</span></span> <span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">then we select Xcode and press the shortcut key (command + control + I) to run it</span> .</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">At this time leaks has run up, we can obviously see,</span></p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="font-family:Arial; font-size:14px; line-height:26px"><span style="color:#cc0000">3.</span></span> <span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">since leaks is dynamic monitoring, we need to manually operate the app, test it, and while operating the app, watch the leaks change,</span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">When the red pillar appears, congratulate you on monitoring the memory leak, click on the second in the upper right corner, for pause detection (also can continue to detect, when more than one pause, one processing a number of),</span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">The following is the location modification</span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000">4.</span> <span style="color:rgb(51,51,51)">at this time, the leaks with the red pillar is selected, there is an "tian" box below, click on it, Select Call Tree</span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Display interface</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000">5.</span> <span style="color:rgb(51,51,51)">here is the most critical step, in the bottom right corner of the interface there are a number of boxes, <span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">Select Invert call Tree and hide System Libraries, (red Circle Range) is shown as Follows:</span> </span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Even if this is basically done here, the two shown here is the memory leak code section, one step further: positioning</p></p><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><span style="color:#cc0000">6.</span> <span style="color:rgb(51,51,51)">Select the day in several bars that appear, double-click, and automatically jump to the memory leak code,</span></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">7, since found the memory leaks out, modify can</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Demo download for testing:</p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">Test Demo<br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px">http://download.csdn.net/detail/u010070526/8995765<br></p></p><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><p class="p1" style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px; margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"><br></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>Latest version addresses iOS memory leaks with Xcode6.4 and instruments, leaks debugging</p></p></span>
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.