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

Store actions in target View tag instead of WeakHashMap #2349

Open
pyricau opened this issue Jan 17, 2023 · 0 comments
Open

Store actions in target View tag instead of WeakHashMap #2349

pyricau opened this issue Jan 17, 2023 · 0 comments

Comments

@pyricau
Copy link
Member

pyricau commented Jan 17, 2023

See here for details: https://py.hashnode.dev/callback-leaks-cancel-your-picasso-requests#heading-weakhashmap

Picasso.targetToActions is a WeakHashMap which prevents leaks in most scenarios, but breaks when providing custom classes such as setting a custom callback in the action with a strong reference to a view.

Consider changing the WeakHashMap<View, Action> to WeakHashMap<View, Void> (i.e. null values) and then storing the actions as view tags with a dedicated int id. That way, the action can only be reached through the view and that will avoid leaks.

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