Resolve message sent to deallocated instance error in LLDB mode

Source: Internet
Author: User

This article is based on the source text to do the collation: http://www.devdiv.com/home.php?mod=space&uid=50901&do=blog&id=50856

Xcode version 7.1 iOS version 9.1

An app that was previously developed by the company, after upgrading to 9.0 in the iOS version of the environment, an action can cause the program to flash back.

Error prompting in Xcode code:

Thread 1:program received signal: "Exc_bad_access"

Such a hint means sending a message to an object that has already been disposed, or calling release on an object that cannot be released.

By default, Xcode does not pinpoint the exact line of code that is causing the problem.

Let's set up the development environment first

First open the Debug Console view interface, allowing Xcode to output more information when debugging: Menu Xcode > Preferences

Set the environment variable again: Menu product > Scheme > Edit scheme

After setting up the debugger, a message sent to deallocated instance error log is found in the output interface

In previous versions of Xcode, we could use info malloc-history 0x6d564f0 in the Xcode console view to see the call stack to see where the crash occurred.

In the new Xcode, the debugger uses the LLDB by default, so how do you locate crash in Lldb state due to improper memory operation?

Open Activity Monitor and find the process number PID for the test app in the list of processes (Xcode will find the app's process in the list of processes when debugging is enabled)

Now we have two main messages:

App Process id:1087

Crash Address: 0X7F7F7523FF10

Open terminal and enter the following command:

1087 0X7F7F7523FF10

Get the error log so that you can locate the line of code that was last called

Downloadbtns is our custom method of releasing the newly built UIButton within this method, which is the culprit that caused the crash.

[BTN release];

Resolve message sent to deallocated instance error in LLDB mode

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.