wasabeef / glide-transformations

An Android transformation library providing a variety of image transformations for Glide.
Apache License 2.0
9.9k stars 1.41k forks source link

Always call destroy on local render script object #194

Open jpelgrim opened 3 years ago

jpelgrim commented 3 years ago

StrictMode reports that the local rs object leaks memory if it does not call destroy() on the local reference. Always calling destroy() explicitly (when not null) fixes this memory leak.

E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'destroy' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:180)
        at android.renderscript.Element.<init>(Element.java:1094)
        at android.renderscript.Element.createPixel(Element.java:1265)
        at android.renderscript.Element.RGBA_8888(Element.java:639)
        at android.renderscript.Allocation.elementFromBitmap(Allocation.java:2762)
        at android.renderscript.Allocation.typeFromBitmap(Allocation.java:2772)
        at android.renderscript.Allocation.createFromBitmap(Allocation.java:2811)
        at jp.wasabeef.glide.transformations.internal.RSBlur.blur(RSBlur.java:39)
        at jp.wasabeef.glide.transformations.BlurTransformation.transform(BlurTransformation.java:79)
        at jp.wasabeef.glide.transformations.BitmapTransformation.transform(BitmapTransformation.java:50)