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

High memory consumption when loading a gif image #2312

Open
3 tasks done
antonzhigalov opened this issue Oct 20, 2024 · 1 comment
Open
3 tasks done

High memory consumption when loading a gif image #2312

antonzhigalov opened this issue Oct 20, 2024 · 1 comment

Comments

@antonzhigalov
Copy link

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

I'm trying to show a gif image in an imageview that results in high memory consumption in the app - over 1GB for a 550KB gif file.

Reproduce

Code example:

import UIKit
import Kingfisher

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let imageView = UIImageView()
        imageView.frame = self.view.bounds
        imageView.kf.setImage(with: URL(string: "https://blog.elfster.com/wp-content/uploads/2024/09/Wish-of-the-Week-2024-Blog-Header-1.gif")!)
        
        self.view.addSubview(imageView)
    }
}
@onevcat
Copy link
Owner

onevcat commented Dec 2, 2024

When using UIImageView to display a gif, by default the whole gif frames are loaded into the memory. If you have a gif with huge frames or large in size, it might cause issues.

To get a better memory performance, consider to use the AnimatedImageView.

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

No branches or pull requests

2 participants