How to troubleshoot message sent to deallocated instance issues under LLDB

Source: Internet
Author: User

Ext.: http://www.devdiv.com/home.php?mod=space&uid=50901&do=blog&id=50856

In previous versions of Xcode, if you encountered a

[Code]C#/CPP/OC Code:
1 message sent to deallocated instance 0x6d564f0
We can use the info malloc-history 0x6d564f0 to look at the call stack to see where the crash occurred, this method is not described here, we Baidu. In the new Xcode, the debugger uses Lldb by default, and I'll talk about how to navigate in Lldb state to crash caused by improper memory operation. First I have a code that crashes: [Code]C#/CPP/OC Code:
1 NSString *themePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:themePathTmp];
2 if(themePath)
3   self.backgroundIV.image = [UIImage imageWithContentsOfFile:[themePath stringByAppendingPathComponent:@"mask_1.png"]];
4   
5 [themePath release];
People who have learned memory management should know that Themepath is not being retain here, so if you write release, it will inevitably crash. First we need to set up the development of environment variables run code, the following crash phenomenon below we open "activity monitor" to find our corresponding PID, our target is Hpthememanager, As long as the hpthememanager corresponding PID can be found (Hpthememanager is downloaded in the forum, is looking at the code, directly to take him to do the experiment) now, We got two main messages: Process id:50127 crash Address: 0x6d564f0 We open the terminal and enter the following command: [Code]C#/CPP/OC Code:
1 sudo malloc_history 50127 0x6d564f0

The results are shown as:

This allows us to navigate to this line of code [code]C#/CPP/OC code:
1 NSString *themePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:themePathTmp];

Troubleshoot Themepath and find the culprit in the crash [code]C#/CPP/OC code:
1 [themePath release];

How to troubleshoot message sent to deallocated instance issues under LLDB

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.