ios - CFNetworkCopyProxiesForAutoConfigurationScript 导致许多内存泄漏
问题描述
CFNetworkCopyProxiesForAutoConfigurationScript
是 Apple 的原生 API,在 CFNetwork 框架中定义。每当我调用此 API 时,此 API 都会留下许多内存泄漏,并且每次调用此 API 时它们都会不断堆积。我使用“Instruments”和“View Memory Graph Heirarchy”选项找到了它也。最后,由于内存问题,它崩溃了。
下面是我正在运行的示例代码。
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;
}
这是内存图的屏幕截图
有没有其他人面临这个问题并对此有任何补救措施?也欢迎任何随意的想法。
解决方案
推荐阅读
- c# - 具有验证规则的文本框仍会在面板移动到其顶部时显示
- python - 包含特征值的函数上的网格网格
- python - 无法在 django 中向用户模型添加两个外键
- powershell - 当它应该是 $False 时得到一个 $True
- html - HTML 导入 Word -> 内联图像尺寸被忽略
- javascript - 从 ChartsJs 创建一个不显示我希望它如何显示的堆叠组图
- django - Django:如何使用“formfield_callback”在“modelform_factory”中指定“include_blank=False”?
- javascript - 如何在 Phaser 中使用 A、S、D、W 键?
- ajax - 如何发出 AJAX 请求并用 laravel 响应?
- firebase - FirebaseAuth 电话验证未在 IOS 上完成事件