iphone ios XCode4如何偵錯工具忽然崩潰而找不到掛的代碼

來源:互聯網
上載者:User

XCode4設定不太一樣: 在Edit–>Scheme裡面 找到Arguments(在xcode 4.2中,在菜單 product->edit scheme中)

把下面3個值設定成YES

NSAutoreleaseFreedObjectCheckEnabled

NSZombieEnabled

NSDebugEnabled

另外轉載2篇調試EXC_BAD_ACCESS的好文http://blog.zol.com.cn/2387/article_2386505.html
http://www.cnblogs.com/likwo/archive/2011/02/28/1967066.html

老外也有這麼說的:I had similar issue; turns out I was
not retaining a UIButton properly. How I found the cause: - Enable zombies - Run the project with 'Allocations' instrument - Use the app to trigger the bug - Check that Instruments show message 'Zombie Messaged' on the timeline - There should be a link that
opens CALayer details: when it was allocated and deallocated - You are interested in the place where is was allocated, should be that aha!!! place in your code


我是用模擬器上 使用zombies,然後運行程式,崩潰的時候會有提示崩潰點,同時有代碼。
轉另一個人文章:

 方法一:

PAEHoldTranMainControl *control = [[PAEHoldTranMainControl alloc]init];

            [self.navigationController pushViewController:control animated:YES];

            [control release];

alloc了一個control,release,運行就崩潰了。而且沒有任何提示,console裡只顯示exc_bad_access

利用NSZombieEnabled參數,MallocStackLogging參數,顯示 -[CALayer release]: message sent to deallocated instance 0x13570810

折騰了半天,最後用如下方法定位問題:

開啟instrument-->ios simulator:

選擇all--》 zombies運行,斷開時,查看stack trace,即可跟蹤

 

 方法二:例如console裡的輸出如下:

TestAPP[1472:207] *** -[NSObject release]: message sent to deallocated instance 0x6019170

在 gdb console 裡面, 運行 shell malloc_history <pid> <mem_address>

pid = process ID (e.g. 1472)

mem_address = memory address of instance (e.g. 0x6019170) 

即會出現調用棧 



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.