setIsActiveResourceRetentionAllowed

open fun setIsActiveResourceRetentionAllowed(isActiveResourceRetentionAllowed: Boolean): GlideBuilder

If set to true, allows Glide to re-capture resources that are loaded into s which are subsequently de-referenced and garbage collected without being cleared.

Defaults to false.

Glide's resource re-use system is permissive, which means that's acceptable for callers to load resources into com.bumptech.glide.request.target.Targets and then never clear the com.bumptech.glide.request.target.Target. To do so, Glide uses s to track resources that belong to s that haven't yet been cleared. Setting this method to true allows Glide to also maintain a hard reference to the underlying resource so that if the com.bumptech.glide.request.target.Target is garbage collected, Glide can return the underlying resource to it's memory cache so that subsequent requests will not unexpectedly re-load the resource from disk or source. As a side affect, it will take the system slightly longer to garbage collect the underlying resource because the weak reference has to be cleared and processed before the hard reference is removed. As a result, setting this method to true may transiently increase the memory usage of an application.

Leaving this method at the default false value will allow the platform to garbage collect resources more quickly, but will lead to unexpected memory cache misses if callers load resources into com.bumptech.glide.request.target.Targets but never clear them.

If you set this method to true you must not call recycle or mutate any Bitmaps returned by Glide. If this method is set to false, recycling or mutating Bitmaps is inefficient but safe as long as you do not clear the corresponding used to load the Bitmap. However, if you set this method to true and recycle or mutate any returned Bitmaps or other mutable resources, Glide may recover those resources and attempt to use them later on, resulting in crashes, graphical corruption or undefined behavior.

Regardless of what value this method is set to, it's always good practice to clear s when you're done with the corresponding resource. Clearing com.bumptech.glide.request.target.Targets allows Glide to maximize resource re-use, minimize memory overhead and minimize unexpected behavior resulting from edge cases. If you use clear, calling recycle or mutating Bitmaps is not only unsafe, it's also totally unnecessary and should be avoided. In all cases, prefer clear to recycle.

Return

This builder.