美文网首页
App中图片特别多,导致内存占用非常高怎么办?

App中图片特别多,导致内存占用非常高怎么办?

作者: York_Lee | 来源:发表于2017-12-08 16:34 被阅读0次

App中图片特别多,导致内存占用非常高怎么办?

在使用SDWebImage加载图片过多导致内存非常高该如何处理

解决

在appdelegate中设置

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[SDImageCache sharedImageCache].maxMemoryCost = 1024 * 1024 * 50;//最多50M内存占用
[SDImageCache sharedImageCache].maxCacheSize = 1024 * 1024 * 50;//最多50M磁盘占用
return YES;
}

如果在某类viewcontroller中收到内存警告还可以清理当前viewcontroller中的内存

-(void)didReceiveMemoryWarning{
[[SDImageCache sharedImageCache] clearMemory];
}

原文出处

相关文章

网友评论

      本文标题:App中图片特别多,导致内存占用非常高怎么办?

      本文链接:https://www.haomeiwen.com/subject/xroeixtx.html