From b101ebe8a63ee1b6fc90135d661f4fe19c2e5f07 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 2 Jul 2014 17:09:34 -0400 Subject: [PATCH] Recycle original screenshot after rotation. After copying the Bitmap to a new Bitmap, there is no need to keep the original pixels. This may help memory pressure when running automated tests and taking lots of screenshots, although it does not fix the main source of the problem. BUG:15454296 Change-Id: I7e61886fbb46a8068db3e8dfa1fcb0afd88ea430 --- core/java/android/app/UiAutomation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index 64e348400c220..4aec9e00e56f6 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -673,6 +673,7 @@ public final class UiAutomation { canvas.translate(- screenshotWidth / 2, - screenshotHeight / 2); canvas.drawBitmap(screenShot, 0, 0, null); canvas.setBitmap(null); + screenShot.recycle(); screenShot = unrotatedScreenShot; }