簡體   English   中英

儀器報告錯誤的內存泄漏?

[英]Instruments reporting false memory leaks?

我在iPad應用程序上運行儀器以檢查是否漏氣。 它在方法中保留對象的地方發現了幾個“泄漏”:

替代文字http://cl.ly/a85d3d8bdc6286c8de71/content

但是這些對象稍后會在dealloc中釋放:

替代文字http://cl.ly/a265f76a538ee55781df/content

這些被歸類為假陽性嗎?

self.detailPopover是否是使用keep聲明的屬性? 如果是這樣,那么賦值self.detailPopover將導致生成的set方法調用對您已經擁有的alloc返回的對象的保留。

如果它是保留屬性,則從分配中刪除self,這樣就不會調用set方法,並且保留計數將是正確的。

Property* prop = [[Property alloc] init]; // retain count == 1 
self.property = prop; // retain count == 2 
[prop release]; // retain count == 1 

或避免生成set方法並保留它...

property = [[Property alloc] init]; // retain count == 1 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM