简体   繁体   中英

Instruments reporting false memory leaks?

I ran Instruments on my iPad app to check for leaks. It found several "leaks" where an object was being retained in a method:

alt text http://cl.ly/a85d3d8bdc6286c8de71/content

But these objects are released later in dealloc:

alt text http://cl.ly/a265f76a538ee55781df/content

Are these classified as false-positives?

Is self.detailPopover a property declared with retain? If so then the assignment self.detailPopover will result in the generated set method calling retain on the object returned from alloc that you already own.

If it is a retained property then remove self from the assignment so the set method is not called and your retain count will be correct.

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

or avoid the generated set method and it's retain...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM