Skip to content

Store actions in target View tag instead of WeakHashMap #2349

@pyricau

Description

@pyricau

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions