简体   繁体   中英

why does “[[UIDevice currentDevice] identifierForVendor]”cause memory leak?

I am using x-code 6.3 instruments to analyze my application, but I don't understand why this line cause memory leak:

+ (NSString*)IDFV
{
    NSUUID* device_id = [[UIDevice currentDevice] identifierForVendor];// !100%
    return [device_id UUIDString];
}

I wanted to post a picture but not enough reputations.

iI chose instruments-leaks-call tree,and select 'invert call tree' and 'hide system libraries',then I got one of the leak codes shows above, can someone help,thanks.

It isn't leaking memory as such

UIDevice currentDevice returns a singleton - that is, each subsequent call to currentDevice will return a reference to the same object instance.

This singleton instance is allocated on the first call to currentDevice and this object will remain allocated until your app exits.

This shows up as a "leak" (and technically is a leak because the object can never be released) but this is by design and nothing to be concerned about.

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