# Callback leaks: cancel your Picasso requests!

DevFeed: [Callback leaks: cancel your Picasso requests!](<https://devfeed.tech/articles/callback-leaks-cancel-your-picasso-requests-25620.md>)

Original publisher: [Read original article](<https://blog.p-y.wtf/callback-leaks-cancel-your-picasso-requests>)

Author: Pierre-Yves Ricau

Published: 2023-01-17T21:06:14Z

Content type: article

Language: en

Sources: [Py's blog](<https://devfeed.tech/sources/py-s-blog.md>)

Topics: [Picasso](<https://devfeed.tech/topics/picasso.md>), [leakcanary](<https://devfeed.tech/topics/leakcanary.md>), [callback](<https://devfeed.tech/topics/callback.md>)

Tags: [actions](<https://devfeed.tech/tags/actions.md>), [adapter](<https://devfeed.tech/tags/adapter.md>), [also](<https://devfeed.tech/tags/also.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-engineer](<https://devfeed.tech/tags/android-engineer.md>), [article](<https://devfeed.tech/tags/article.md>), [block](<https://devfeed.tech/tags/block.md>), [callback](<https://devfeed.tech/tags/callback.md>), [engineer](<https://devfeed.tech/tags/engineer.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [i](<https://devfeed.tech/tags/i.md>), [leak](<https://devfeed.tech/tags/leak.md>), [leakcanary](<https://devfeed.tech/tags/leakcanary.md>), [leaks](<https://devfeed.tech/tags/leaks.md>), [learn](<https://devfeed.tech/tags/learn.md>), [look](<https://devfeed.tech/tags/look.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [performance](<https://devfeed.tech/tags/performance.md>), [picasso](<https://devfeed.tech/tags/picasso.md>), [this](<https://devfeed.tech/tags/this.md>), [top](<https://devfeed.tech/tags/top.md>), [work](<https://devfeed.tech/tags/work.md>)

## AI overview

A Picasso request can keep a detached UI component from being garbage collected when its custom callback captures the component and the request remains in flight. Picasso's singleton holds weak references to target views but strong references to actions; the action and callback can therefore retain the detached view. Cancel requests when the UI goes away to prevent the leak and avoid continued resource use while loading. The excerpt also says Picasso automatically cancels a previous request when a new image is loaded into the same ImageView, which helps with recycled adapter views. It cuts off during that explanation, so it does not establish the full set of circumstances in which leaks are avoided.

## Source excerpt

👋 Hi, this is P.Y., I work as an Android Engineer at Block. Every month I organize an internal Ensemble Leak Hunting session where we look at the top leaks reported by LeakCanary to learn how to read