SDWebImage: Extremely high memory usage, NSCollectionView
Platform Name: macOS Platform Version: 10.13.2 (17C205) SDWebImage Version: 4.2.3 Integration Method: Cocoapods Xcode Version: 9.2 (9C40b) Language: Swift 4
Hi guys,
I am using SDWebImage for download/show images to NSImageView inside NSCollectionView (flow layout) cells. images are located in AWS s3, image’s resolutions are 1280 × 853 (standard for all images) and file sizes varies between 110-190 kbyte. using HTTP instead of HTTPS, I can confirm images are cached alright because I do not see network activity after first pass, all images comes from cache. In the collection view there are 200 images max at the same time.
When I am creating NSCollectionViewItems and most of the objects I am using “unowned” / “weak” declarations, in deinit I am setting all possible objects to nil. I can tell there is no related leak when I check it with Instruments. There are some leaks but they comes from standard swift libraries and 200-300k in total.
Usage is pretty standard:
cell.imageView.sd_setImage(with: img_url, completed: nil)
Following config values set to false:
SDImageCache.shared().config.shouldDecompressImages
SDWebImageDownloader.shared().shouldDecompressImages
in a loop every 30 seconds calling
SDImageCache.shared().clearMemory()
After couple of times scrolled down then up memory usage hits to 1 - 1.5 GB in average for per tab. If I keep scrolling it climbs up… Even after I destroyed the window controller (cmd + w), it is not releasing memory. I can see deinit called.
To be sure is it my code or the library I added Kingfisher library in to my project, memory usage did not go up more than 600Mb for per tab. And released afterwards.
Last 4 days, I read every line in issues about high memory usage, tried everything in my knowledge but I stuck. I believe something wrong with the library when use it with macOS because there is no issue on IOS for same cases.
Actually i am writing new version of an old app of mine from 2013, it is using SDWebImage as well and it’s memory usage average is around 300-400Mb for per tab.
Any help or suggestions would be appreciated. I would like to post my project but it is huge.
I prepared a new project for test, please see attached zip file. If you scroll down and up couple of times you will see the extreme memory usage.
Cheers.
SDWebImageTest.zip Extremly
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
@dreampiggy sorry for delay, i got cold, can’t working right now. I will let you know asap once I get up
@dreampiggy hi, when I do pod install, here is the result and thank you so much for looking into this.
Pre-downloading:
SDWebImagefromgit@github.com:rs/SDWebImage.git, branchfix_running_operation_leak[!] Error installing SDWebImage [!] Failed to download ‘SDWebImage’.
Cheers, -mohac.