Sdwebimage: Caching images in disk only, but not in memory. Is that possible?

Created on 10 May 2013  路  22Comments  路  Source: SDWebImage/SDWebImage

My app takes up a lot of memory already, I want to reduce memory usage as much as possible.

feature

Most helpful comment

@gmogames This feature was added in 3.7.4 release. You just need to use the shouldCacheImagesInMemory property from SDImageCache and set it to NO.

All 22 comments

I'v tried using [[SDImageCache sharedImageCache] clearMemory];, but it didn't seem to work.

See this thread: https://twitter.com/0xced/status/332252283758845953

Better solution soon.

Hi All!

I Have tried calling [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"]
at the end of loop of 160 Images (JPG 800x600)
but memory cache still raise...

My problem it's that real memory and virtual memory reach high values and app crashed before the Mem Warning

@rs not sure what the "better solution soon" is, but I would like to add my voice to wanting this ability.

I'm trying to use SDWebImage to solve numerous problems in an app I work on. Much of the time the app images are thumbnails in UITableViewCell's so it's simple enough to just use the UIImageView category. But there's a feature in the app where you can "download all app content" for things like Airplane Mode use. So of course, I'd want to piggyback into SDWebImage's mechanism so there's one way for all image management. It would be welcome to have a way to purely download the images and save onto disk, no memory caching, very simple and efficient file download.

One thing I also have to contend with is this server transition we're going through. The old way had the server processing the images and putting them on the server with constantly unique URL's, so detecting "changes to the image" was never difficult, just check against the URL. Thus our SDWebImage use wouldn't need any options. However, the new server doesn't necessarily provide unique URL's (tho the HTTP headers should have Last-Modified and Expires headers); so for that server I've been trying to use SDWebImageRefreshCached to always ensure we get the latest and right one, even if it's a performance hit (need to be correct first, fast second). So I don't know how this might factor into your solution, but I figured it might be useful to mention.

Thank you for listening.

+1 I would love to see this happen! I am struggling with the same issues atm.

+1 I need this feature too.

+1 I would love to have the ability to either turn off in memory caching or at least control the size of it without altering the source code.

[[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"]; works, but I feel like it is a not so pretty workaround. Also you would need to have it in multiple places because when you retrieve an image from the disk cache it is added to the memory cache so you would have to run this call again.

Would be awesome to see this feature added. I am sure many people would benefit greatly from it.

+1

+1

+1

+1

+1

+1

everyone interested should try this pull

+1

@Savankumar-vaishnav this is already done via https://github.com/rs/SDWebImage/pull/1217

+1

@gmogames This feature was added in 3.7.4 release. You just need to use the shouldCacheImagesInMemory property from SDImageCache and set it to NO.

+1

In case this saves anyone else time, in recent SDWebImage this property has moved to SDImageCache.config.shouldCacheImagesInMemory

SDImageCache.config.shouldCacheImagesInMemory = NO doesn't work for me :(

Here is the new syntax to use SDImageCache.shared().config.shouldCacheImagesInMemory = false

Was this page helpful?
0 / 5 - 0 ratings