1.- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{} // 這個方法有內存泄露
// leo加了這個:防止內存泄露!
[session finishTasksAndInvalidate];
2.一個好的鏈接說明SDWebImage的內存問題:
http://www.lxweimin.com/p/e6e52efc5a35
3.UIImage *diskImage = [self diskImageForKey:key];引起的內存增長
清除cache,只要在合適的時機去調用它就行
[[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
網上說把它放在applicationDidReceiveMemoryWarning里調用,但是我沒有,因為在一些老機型里,比如iPhone4,內存爆炸的時候瞬間就crash了,來不及去調這個,所以我建議在做一些大圖片多圖片處理的時候,最好隨時的去清理一下。
4.查看我的文章《新的SDWebImageCache.m解決內存增加很多...》
我測試了,這個還是不行,草!
5.SDWebImage內存泄露
https://github.com/rs/SDWebImage/issues/53
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
solved the problem before return cell.