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

ImageView retained by kingfisher when it should be dealloc #2313

Open
1 of 3 tasks
bing-feng-v587 opened this issue Oct 23, 2024 · 4 comments
Open
1 of 3 tasks

ImageView retained by kingfisher when it should be dealloc #2313

bing-feng-v587 opened this issue Oct 23, 2024 · 4 comments

Comments

@bing-feng-v587
Copy link

bing-feng-v587 commented Oct 23, 2024

Check List

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

Issue Description

What

when vc poped, imageview should dealloc, but it not happend when loading image use kingfisher.
and it real deinit after load remote image finish.

kingfier retain imageview by self.base

Reproduce

[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]

Other Comment

[Add anything else here]

@onevcat
Copy link
Owner

onevcat commented Oct 23, 2024

As the KingfisherWrapper itself is a struct (which contains the actual image view as a reference), it would be quite difficult to prevent the holding in the closure. If the extended lifetime is not desired, you can try to call cancelDownloadTask on the imageView.kf to terminate the processing:

class MyViewController: UIViewController {
    deinit {
        imageView.kf.cancelDownloadTask()
    }
}

@bing-feng-v587
Copy link
Author

wow, it used in many places. This approach doesn't seem to work.
Will there be no optimization for this area in the future?

@Adobels
Copy link

Adobels commented Nov 11, 2024

@bing-feng-v587 When you write, ‘This approach doesn’t seem to work,’ do you mean that the proposed solution isn’t fixing the problem, or is it not acceptable for your project because there are many parts of your codebase that would need to be adapted?

@bing-feng-v587
Copy link
Author

yes, there are many parts in my code that need to be adapted

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

3 participants