(1)、Leaked memory: Memory unreferenced by your application that cannot be used again or freed (also detectable by using the Leaks instrument).
(2)礼华、Abandoned memory: Memory still referenced by your application that has no useful purpose.
(3)、Cached memory: Memory still referenced by your application that might be used again for better performance
其中 Leaked memory 和 Abandoned memory 都屬于應(yīng)該釋放而沒釋放的內(nèi)存粘茄,都是內(nèi)存泄露,而 Leaks 工具只負(fù)責(zé)檢測 Leaked memory秕脓,而不管 Abandoned memory柒瓣。在 MRC 時代 Leaked memory 很常見,因為很容易忘了調(diào)用 release撒会,但在 ARC 時代更常見的內(nèi)存泄露是循環(huán)引用導(dǎo)致的 Abandoned memory嘹朗,Leaks 工具查不出這類內(nèi)存泄露师妙,應(yīng)用有限诵肛。
xcode8 打開Instruments;
1.快捷鍵打開 ?command +shift + i ? 或者Xcode->Open Developer Tool ->Instruments
出現(xiàn)如下界面 :
選擇leaks .
2.運行Xcode上的項目 然后在?
然后在運行l(wèi)eaks. leaks上面會顯示紅色方塊 紅色方塊就是leaks.
3.點擊紅色小方塊?
然后選擇details->call tree ->call tree ??
4.設(shè)置過濾狀態(tài) 選擇 選中Invert Call Tree 和Hide System Libraries.
效果如圖?
有的xcode不一樣 ?如下?
然后雙擊 symbol Name 里面的leaks 名字 就可以跳到 內(nèi)存泄漏的部分?
5. 如果 顯示的是16進(jìn)制的數(shù)據(jù) 不是代碼的話 那么需要設(shè)置一下xcode 選擇Bulid Settings 里面的 debug in? 選擇第二個 DWARF with dSYM File.
到此就完成了 小伙伴們 去實驗吧.