Leaks in Swift 3 / iOS 10 -
when i'm running instruments , check leaks, it's showing leaks consisting of:
_contiguousarraystorage<string> _nativedictionarystorageowner<int, cgfloat> _nativedictionarystorageowner<string, anyobject>
this when i'm using swift 3 , testing on devices using ios 10.
the leaks show in ios 10 while on ios 9.x seems normal. on top of that, in ios 10 uiswitch
doesn't seem deallocate either.
currently i've been creating kinds of workarounds trying avoid using dictionaries , in cases arrays, making annoying code.
question:
should concerned , try fix these leaks or wait , hope fixed in future updates? if so, there anywhere check bugs known etc?
i had same problem , spent lot of time digging. found if create swift object objective-c code , swift object has native swift dictionary property, see leak. won't happen if code swift, , more usefully, won't leak if change native swift dictionary nsdictionary. applies swift set's , nsset's. saw leak happens on ios 10 , not on ios 9.
// leakyswiftobject.swift class leakyswiftobject: nsobject { let dict = [string: string]() // <- native swift dictionary reproduce leak } // objectivecobject.h @class leakyswiftobject; @interface objectivecobject : nsobject @property (strong) leakyswiftobject *leaky; @end // objectivecobject.m @implementation objectivecobject - (instancetype)init { self = [super init]; if (self) { self.leaky = [leakyswiftobject new]; } return self; } @end // viewcontroller.swift class viewcontroller: uiviewcontroller { let testobj = objectivecobject() }
the leaks instrument reports leak:
_nativedictionarystorageimpl<string,string
>
_nativedictionarystorageowner<string,string
>
Comments
Post a Comment