@eskimo
as of 2022-02-25, we came across this thread from another article saying calling CNCopyCurrentNetworkInfo will lead to massive memory leak, with Xcode 13.2.1, iOS 14, while the app has no location auth and call this API. It will return NULL, and lots of internal objects leak, please see attached screenshot.
our test code:
for (int i = 0; i < 100000; i++) {
@autoreleasepool {
NSString *ssid = [UIDevice currentWifiSSID];
NSString *bssid = [UIDevice currentWifiBSSID];
}
}
currentWifiBSSID will be like:
NSArray *interfaces = (__bridge_transfer NSArray *)CNCopySupportedInterfaces();
NSString *ssidStr = nil;
for (NSString *name in interfaces) {
NSDictionary *networkInfo = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)name);
ssidStr = [networkInfo objectForKey:(__bridge NSString *)kCNNetworkInfoKeySSID];
if([ssidStr isKindOfClass:[NSString class]] && ssidStr.length > 0) {
return ssidStr.copy;
}
}
return nil;
}
Any plan to fix CNCopyCurrentNetworkInfo?