-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
High memory use #1544
Comments
whats the size of the image you are trying to download? |
did you try setting these two:
by the way, whats the highest resolution of those images? |
No, i havent, i will try this code... The API returns me a lot of images already resized, so i choose witch one to use, depending of the iPhone resolution(100x100, 200x200, 500x500, 1000x1000, 1500x1500, 2000x2000) |
Btw, where should I use this code? appdelegate or viewcontroller? |
should be before you make your requests. try the appdelegate |
On viewcontroller nothing changed... still increasing memory |
the 100x100 pixels image is about 4kb... and increase a lot of memory |
why are you using SDWebImageManager's |
i cant show the image as soon as the dowload finish, i have to implement some logic before with the image... |
if you perform extra actions on the image you could use this did you try the demo project? does it show the same memory increase? |
i will try right now |
it still increasing memory with the code bellow:
|
also have checked all strong and weak properties referencies... just to double check if the ARC is releasing all object correctly, but it's all right with it |
try the demo project with your API urls but without doing anything extra to the image after download. do you still see any increase in memory? |
I have to go now, but i will try in about 2 hours, tks by now |
@CavalcanteLeo any updates? Any chance you are using animated (GIF) images? |
by changing setShouldDecompressImages to YES, in some benchmarks, my app performance went from 600mb to about 40mb
and then from 50mb to about 6mb with this:
also set some other properties (no impact changed):
and on each viecontroller i clean the cache on viewDidDisappear and didReceiveMemoryWarning
but now, my problem is app performance, as i set ShouldDecompressImages to NO. |
Did you try to activate the address sanitizer in your scheme? I have myself a crash because of sdwebimage when i activate it. |
We have also been monitoring an issue with RAM usage being way to high. We upgraded to v3.7.6 and followed the example above. e.g.:
What we found is this significantly increased the RAM usage by a factor of 2-2.5. We decided to downgrade to v3.7.3 and changed the following:
Our previous code using v3.7.3 was:
By downgrading to v3.7.3 and setting the two above methods to |
I am using 3.7.3 and did the code like |
@SpaceStar2016 If you're using pod 'SDWebImage', '3.7.3' then run Remove the line: Hopefully this will help. |
@ynotski I am sure I am using 3.7.3 I can code [[SDImageCache sharedImageCache] setShouldCacheImagesInMemory:NO] in my project. |
After lots of R&D and applying all kind of options for SDImageCache, I have finalized below options to set to avoid crash on heavy images load with the Best performance on RAM cache load: Hope this will help you all !!! Add below code into your AppDelegate class: import SDWebImage
How to use: //MARK:- Load Image with Activity Indicator
|
Thanks @smindia1988 for sharing these settings |
great work.Thanks @smindia1988 |
@SDWebImage/collaborators should we list those settings to our docs or even README page? They might come in handy for a good number of our users. |
I suppose add a section of |
@smindia1988 |
@ACode-Farmer Use .avoidDecodeImage. You can also use the OptionsProcesser for global control instead of invidual image request control. See #2736 I'll update the Wiki soon about this. Seems out of date. |
Thanks for your reply. @dreampiggy |
RAM usage for bitmap image usage, the fomula is really simple: Pixel Count * 4. For you demo image, it's a The So, you'd better choose another idea for this, such as preprocess the image with lower resolution on Server, or using something on the Client like Wiki - Image Transformer. To scale down the resolution for images. If you Really need to display large resolution. You can also try to use the CATiledLayer to display super large images. Which means, you don't load the image entirely into memory, you load them by tiles, the size is much more smaller than full size. Then, track the user's scroll and load another tile, etc. This is just the technology used by Map apps (For example, a full map bitmap image may be 100000*100000 pixels, this can not been hold in RAM at all). |
@ACode-Farmer Update the documentation, see Wiki - Optimization for large images |
Thanks @dreampiggy |
The documentation is updated to latest SDK name. The options processor is available in 5.1.0, the other is available in 5.0.0. See wiki: https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#options-processor-510 |
The text was updated successfully, but these errors were encountered: