为什么“[[UIDevice currentDevice] identifierForVendor]”会导致内存泄漏?
why does "[[UIDevice currentDevice] identifierForVendor]"cause memory leak?
我正在使用 x-code 6.3 工具来分析我的应用程序,但我不明白为什么这一行会导致内存泄漏:
+ (NSString*)IDFV
{
NSUUID* device_id = [[UIDevice currentDevice] identifierForVendor];// !100%
return [device_id UUIDString];
}
我想post一张图片但是没有足够的声望。
我选择了 instruments-leaks-call 树,然后 select 'invert call tree' 和 'hide system libraries',然后我得到了上面显示的泄漏代码之一,有人可以帮忙吗,谢谢。
这不是内存泄漏本身
UIDevice currentDevice
return 是一个单例 - 也就是说,对 currentDevice
的每个后续调用都将 return 引用同一对象实例。
此单例实例在第一次调用 currentDevice
时分配,此对象将保持分配状态直到您的应用程序退出。
这显示为 "leak"(从技术上讲是泄漏,因为该对象永远无法释放)但这是设计使然,无需担心。
我正在使用 x-code 6.3 工具来分析我的应用程序,但我不明白为什么这一行会导致内存泄漏:
+ (NSString*)IDFV
{
NSUUID* device_id = [[UIDevice currentDevice] identifierForVendor];// !100%
return [device_id UUIDString];
}
我想post一张图片但是没有足够的声望。
我选择了 instruments-leaks-call 树,然后 select 'invert call tree' 和 'hide system libraries',然后我得到了上面显示的泄漏代码之一,有人可以帮忙吗,谢谢。
这不是内存泄漏本身
UIDevice currentDevice
return 是一个单例 - 也就是说,对 currentDevice
的每个后续调用都将 return 引用同一对象实例。
此单例实例在第一次调用 currentDevice
时分配,此对象将保持分配状态直到您的应用程序退出。
这显示为 "leak"(从技术上讲是泄漏,因为该对象永远无法释放)但这是设计使然,无需担心。