Authored by DreamPiggy
Committed by GitHub

Merge pull request #2153 from dreampiggy/improve_duplicate_memory_warning

Remove the extra memory warning notification for AutoPurgeCache
@@ -11,31 +11,6 @@ @@ -11,31 +11,6 @@
11 #import "NSImage+WebCache.h" 11 #import "NSImage+WebCache.h"
12 #import "SDWebImageCodersManager.h" 12 #import "SDWebImageCodersManager.h"
13 13
14 -// See https://github.com/rs/SDWebImage/pull/1141 for discussion  
15 -@interface AutoPurgeCache : NSCache  
16 -@end  
17 -  
18 -@implementation AutoPurgeCache  
19 -  
20 -- (nonnull instancetype)init {  
21 - self = [super init];  
22 - if (self) {  
23 -#if SD_UIKIT  
24 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];  
25 -#endif  
26 - }  
27 - return self;  
28 -}  
29 -  
30 -- (void)dealloc {  
31 -#if SD_UIKIT  
32 - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];  
33 -#endif  
34 -}  
35 -  
36 -@end  
37 -  
38 -  
39 FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { 14 FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
40 #if SD_MAC 15 #if SD_MAC
41 return image.size.height * image.size.width; 16 return image.size.height * image.size.width;
@@ -90,7 +65,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { @@ -90,7 +65,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
90 _config = [[SDImageCacheConfig alloc] init]; 65 _config = [[SDImageCacheConfig alloc] init];
91 66
92 // Init the memory cache 67 // Init the memory cache
93 - _memCache = [[AutoPurgeCache alloc] init]; 68 + _memCache = [[NSCache alloc] init];
94 _memCache.name = fullNamespace; 69 _memCache.name = fullNamespace;
95 70
96 // Init the disk cache 71 // Init the disk cache