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]; |
3 |
self.backgroundIV.image = [UIImage imageWithContentsOfFile:[themePath stringByAppendingPathComponent: @"mask_1.png" ]]; |
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:
Original address: http://www.devdiv.com/lldb_message_sent_to_deallocated_instance_-blog-50901-50856.html
Debug message Send to deallocated instance issue