SDWebImage对缓存对象的大小

Kar*_*207 4 iphone ipad ios sdwebimage swift

我想计算SDWebImage占用的当前内存大小(不是SDWebImage的最大大小).在应用程序使用期间,我需要跟踪SDWebImage缓存对象的当前RAM分配.

基本上我想计算NSCache对象中所有图像(当时存在)的大小.

我怎样才能做到这一点 ?

谢谢.

tec*_*erd 5

我认为这将使用给定的代码返回Memory Cache.

使用getSize功能SDImageCache.h.哪个返回内存缓存.

[[SDImageCache sharedImageCache] getSize];
Run Code Online (Sandbox Code Playgroud)

请关注SDWebImage以获取更多详细信息.


Ram*_*ury 2

你的意思是这个吗,摘自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;`
Run Code Online (Sandbox Code Playgroud)

那么总字节数就是内存中保存的像素数 * 每个像素的字节数,在本例中为 4 字节/像素