clearOnDetach

fun clearOnDetach(): ViewTarget<T, Z>

Clears the View's Request when the View is detached from its and restarts the Request when the View is re-attached from its android.view.Window.

This is an experimental API that may be removed in a future version.

Using this method can save memory by allowing Glide to more eagerly clear resources when transitioning screens or swapping adapters in scrolling views. However it also substantially increases the odds that images will not be in memory if users subsequently return to a screen where images were previously loaded. Whether or not this happens will depend on the number of images loaded in the new screen and the size of the memory cache. Increasing the size of the memory cache can improve this behavior but it largely negates the memory benefits of using this method.

Use this method with caution and measure your memory usage to ensure that it's actually improving your memory usage in the cases you care about.