SDWebImage引发的内存大量消耗

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
     NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
   
    [[SDImageCache sharedImageCache] setShouldDecompressImages:NO];
    [[SDWebImageDownloader sharedDownloader] setShouldDecompressImages:NO];
}


- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
    // 赶紧清除所有的内存缓存
    [[SDImageCache sharedImageCache] clearMemory];
//    [[SDImageCache sharedImageCache] clearDisk];
    // 赶紧停止正在进行的图片下载操作
    [[SDWebImageManager sharedManager] cancelAll];
}

还有一种情况,当UITableView滑动加载很多图片 内存也会突然消耗很多,如果是从阿里云服务器下载的图片,一定要裁剪,减小图片的大小。

posted @ 2018-09-10 23:33  createstone  阅读(93)  评论(0)    收藏  举报