From 314964c5f98c6699599df0f47ae2b4b2d8020b40 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 27 Mar 2021 14:44:45 +0100 Subject: [PATCH] Recycle Bitmap in transformation --- app/src/main/java/org/schabi/newpipe/player/Player.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index df0812c29..72540453d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -1235,12 +1235,18 @@ public final class Player implements context.getResources() .getDimension(R.dimen.player_notification_thumbnail_width), source.getWidth()); - return Bitmap.createScaledBitmap( + + final Bitmap result = Bitmap.createScaledBitmap( source, (int) notificationThumbnailWidth, (int) (source.getHeight() / (source.getWidth() / notificationThumbnailWidth)), true); + + if (result != source) { + source.recycle(); + } + return result; } @Override