Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching images in disk only, but not in memory. Is that possible? #391

Closed
yorkwang opened this issue May 10, 2013 · 23 comments · Fixed by #1217
Closed

Caching images in disk only, but not in memory. Is that possible? #391

yorkwang opened this issue May 10, 2013 · 23 comments · Fixed by #1217
Labels
Milestone

Comments

@yorkwang
Copy link

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

@yorkwang
Copy link
Author

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

@rs
Copy link
Member

rs commented May 10, 2013

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

Better solution soon.

@ultranano
Copy link

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

@hsoi
Copy link
Contributor

hsoi commented Jun 19, 2013

@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.

@arun057
Copy link

arun057 commented Jul 18, 2013

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

@gongpengjun
Copy link

+1 I need this feature too.

@joshuafeldman
Copy link
Contributor

+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.

@peterjenkins
Copy link

+1

1 similar comment
@voronianski
Copy link

+1

@bpoplauschi bpoplauschi added this to the Future milestone Jun 17, 2014
@schazers
Copy link

+1

1 similar comment
@timbornholdt
Copy link

+1

@weirdpipo
Copy link

+1

1 similar comment
@marcelosalloum
Copy link

+1

@mythodeia
Copy link
Contributor

everyone interested should try this pull

@Savankumar-vaishnav
Copy link

+1

@mythodeia
Copy link
Contributor

@Savankumar-vaishnav this is already done via #1217

@bpoplauschi bpoplauschi modified the milestones: 3.7.4, 4.0.0 Dec 17, 2015
@gmogames
Copy link

+1

@bpoplauschi
Copy link
Member

@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.

@AlfredDuck
Copy link

+1

@bcattle
Copy link

bcattle commented Sep 22, 2017

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

@trannguyenvu91
Copy link

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

@arrabidas92
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.