CFNetworkCopyProxiesForAutoConfigurationScript causing many memory leaks

无人久伴 提交于 2019-12-24 00:52:04

问题


CFNetworkCopyProxiesForAutoConfigurationScript is Apple's native API, defined in CFNetwork framework.Whenever I call this API many memory leaks are left by this API and they keep on piling with each call to this API.I found it using "Instruments" and "View Memory Graph Heirarchy" option too. At the end it crashes due to memory issues.

Below is the sample code that I am running.

CFErrorRef err = NULL;
NSString *strURL = @"http://www.google.com";
CFStringRef tempPacdata = CFStringCreateCopy(kCFAllocatorDefault, (__bridge CFStringRef)pacFileData);
CFURLRef tempURLref = CFURLCreateWithString(kCFAllocatorDefault, (__bridge CFStringRef)strURL, nil);
CFArrayRef proxies = CFNetworkCopyProxiesForAutoConfigurationScript(tempPacdata, tempURLref, &err);

strURL = nil;
if (proxies != NULL)
{
CFRelease(proxies);
proxies = NULL;
}

if (tempPacdata != NULL)
{
CFRelease(tempPacdata);
tempPacdata = NULL;
}
if (tempURLref != NULL)
{
CFRelease(tempURLref);
tempURLref = NULL;
}

Here is the screenshot from Memory Graph

Has anyone else facing this issue and got any remedy for this?Any random thoughts are welcome too.

来源:https://stackoverflow.com/questions/50154317/cfnetworkcopyproxiesforautoconfigurationscript-causing-many-memory-leaks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!