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];
}