運(yùn)行程序時(shí)沒有錯(cuò)誤提示,出現(xiàn)如下信息
項(xiàng)目(702,0x198497310) malloc: stack logs being written into /private/var/mobile/Containers/Data/Application/461E4C49-CF65-49F6-8B76-AF30533D5390/tmp/stack-logs.702.100098000.TableDelete.3JtuAw.index
項(xiàng)目(702,0x198497310) malloc: recording malloc and VM allocation stacks to disk using standard recorder
項(xiàng)目(702,0x198497310) malloc: process 668 no longer exists, stack logs deleted from /private/var/mobile/Containers/Data/Application/461E4C49-CF65-49F6-8B76-AF30533D5390/tmp/stack-logs.668.1000a4000.TableDelete.CtzS13.index
將整個(gè)項(xiàng)目的源代碼復(fù)制到別一個(gè)新建的項(xiàng)目中,再運(yùn)行就沒有問題了!
另:
在原來的項(xiàng)目中,使用debug模式啟動(dòng)項(xiàng)目就會(huì)出上面的錯(cuò)誤,但不以debug模式啟動(dòng)時(shí)就能正常啟動(dòng)....
解決方法:
打開edit scheme ,在run模式下 取消Logging下的malloc stack選項(xiàng)即可(注:如果memory management下的enable guard malloc選項(xiàng)啦租,則程序崩潰)
NSZombieEnabled選項(xiàng)打開后,crash時(shí)能打印出具體的對(duì)象地址拱撵;Malloc Stack選項(xiàng)打開后着饥,可以通過命令行打印出程序分配與釋放空間的歷史。兩者相互結(jié)合摇天,往往就能發(fā)現(xiàn)到底是什么對(duì)象被意外釋放了粹湃。
另附上 xcode EXC_BAD_ACCESS調(diào)試
1.進(jìn)入edit scheme 設(shè)置頁面
2.在diagnostics面板中enable zombie objects和malloc stack選項(xiàng)
3.把xcode默認(rèn)的debugger設(shè)置為GDB
4.當(dāng)出現(xiàn)message sent to deallocated instance ***,鍵入info malloc-history ***5.根據(jù)堆棧信息泉坐,定位到內(nèi)存泄露的代碼
截圖如下:
我猜你是打開了Run菜單下的Enable Guard Malloc的設(shè)置