6

I wanted to calculate the current in-memory size occupied by SDWebImage (Not the max size of SDWebImage). During the application usage i need to track the current RAM allocation by SDWebImage cached objects.

Basically i wanted to calculate the size of all images (present at that time) in NSCache object.

How can i do this ?

Thanks.

Mayur Prajapati
  • 5,454
  • 7
  • 41
  • 70
Karthik207
  • 493
  • 9
  • 27

2 Answers2

7

I think this will return Memory Cache using given code.

Use getSize function of SDImageCache.h. Which returns in memory cache.

[[SDImageCache sharedImageCache] getSize];

Follow SDWebImage for more details.

technerd
  • 14,144
  • 10
  • 61
  • 92
2

do you mean this, taken from SDWebImageCache.h:

/**
  * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
  */

  @property (assign, nonatomic) NSUInteger maxMemoryCost;`

then total number of bytes is number of pixels held in memory * number of bytes per pixel, in this case 4 Bytes/Pixel

Ramy Kfoury
  • 937
  • 5
  • 8