ios - 获得内存压力通知(关键/非关键) - iOS Objective-c
问题描述
收到内存压力通知(关键/非关键)。
在 tableview 中从 API 加载的“n”张图像。但是该应用程序在几秒钟后因上述错误而崩溃。当前的代码是,
[post_img sd_setImageWithURL:[NSURL URLWithString:[arr objectAtIndex:i]] placeholderImage:[UIImage imageNamed:@"placeHolder.jpg"] options:SDWebImageRefreshCached];
我试过删除缓存,
[[SDImageCache sharedImageCache] removeImageForKey:[arr objectAtIndex:i] fromDisk:YES withCompletion:nil];
另外,我尝试使用 dispatchqueue 获取图像,
dispatch_async(dispatch_get_global_queue(0,0), ^{
NSData * data = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: [arr objectAtIndex:i]]];
if ( data == nil )
return;
dispatch_async(dispatch_get_main_queue(), ^{
post_img.image = [UIImage imageWithData: data];
});
});
但我仍然得到错误。
解决方案
推荐阅读
- amazon-web-services - AWS 已经创建了 EC2 实例并忘记创建端口 5000
- amazon-web-services - AWS Code Pipeline 如何访问其他组织中的存储库(我拥有存储库的管理员访问权限)
- mysql - C3PO:客户端在等待获取资源时超时
- ruby - 无法将 gem 推送到正确的链接
- ansible - 如何自动配置 Azure B2C?
- javascript - Mongoose:将对象插入子文档数组
- python - 附加在熊猫中 - 逐行
- node.js - Electron process.dev 配置不起作用?
- javascript - 预提交 + python + react (js)
- reactjs - 'Element' 类型的参数不可分配给 ReactElement 类型的参数