diff --git a/BlurEffect/src/com/npi/blureffect/Blur.java b/BlurEffect/src/com/npi/blureffect/Blur.java index 500bb40..a84393d 100644 --- a/BlurEffect/src/com/npi/blureffect/Blur.java +++ b/BlurEffect/src/com/npi/blureffect/Blur.java @@ -29,6 +29,12 @@ public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) { script.setInput(input); script.forEach(output); output.copyTo(bitmap); + + if(bitmap != sentBitmap) { + // To avoid memory leaks + sentBitmap.recycle(); + } + return bitmap; } @@ -258,6 +264,12 @@ public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) { Log.e("pix", w + " " + h + " " + pix.length); bitmap.setPixels(pix, 0, w, 0, 0, w, h); + + if(bitmap != sentBitmap) { + // To avoid memory leaks + sentBitmap.recycle(); + } + return (bitmap); }