From b279330c0a0c380e038ada6e92ac852f3a3f8f75 Mon Sep 17 00:00:00 2001 From: daqi Date: Sat, 17 Jun 2017 15:24:44 +0800 Subject: [PATCH] Fix PremiumSmsAccess memory leak [Cause of Defect] PremiumSmsAccess forget to invoke Session and AppStateSmsPremBridge release method in the onDestroy callback. And that would lead to the leak of activity context. Test: 1. Settings - Apps - Advanced - Special access - Premium SMS access 2. adb shell dumpsys meminfo com.android.settings 3. observe activity object number 4. back to the last page 5. use AS trigger Settings gc several times 6. adb shell dumpsys meminfo com.android.settings 7. observe activity object number to check if the activity number decrease Change-Id: I359900c16fa866fba94d187a61cf6bebbdd1ed0b Signed-off-by: daqi --- src/com/android/settings/applications/PremiumSmsAccess.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/android/settings/applications/PremiumSmsAccess.java b/src/com/android/settings/applications/PremiumSmsAccess.java index c4bb1a80fd..1bc561bd84 100644 --- a/src/com/android/settings/applications/PremiumSmsAccess.java +++ b/src/com/android/settings/applications/PremiumSmsAccess.java @@ -76,6 +76,13 @@ public class PremiumSmsAccess extends EmptyTextSettings implements Callback, Cal } @Override + public void onDestroy() { + mSmsBackend.release(); + mSession.release(); + super.onDestroy(); + } + + @Override protected int getMetricsCategory() { return MetricsProto.MetricsEvent.PREMIUM_SMS_ACCESS; } -- 2.11.0