From 669b633e9d1907d4efe2410220d6fc36019b39e8 Mon Sep 17 00:00:00 2001 From: David Saff Date: Thu, 1 Dec 2022 12:57:45 -0500 Subject: [PATCH] Clear TestableLoopers in SysuiTestCase Bug: 261039202 Test: presubmit to verify this doesn't break existing tests Test: See b/259992416 for analysis of how this improves memory pressure. Change-Id: Ifa1b489b8dff354a29727fb61342ac9b82ec65e7 --- .../tests/utils/src/com/android/systemui/SysuiTestCase.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java index fa3cc9905c3f4..bf2235aa98a9b 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCase.java @@ -136,6 +136,8 @@ public abstract class SysuiTestCase { InstrumentationRegistry.getArguments()); if (TestableLooper.get(this) != null) { TestableLooper.get(this).processAllMessages(); + // Must remove static reference to this test object to prevent leak (b/261039202) + TestableLooper.remove(this); } disallowTestableLooperAsMainThread(); mContext.cleanUpReceivers(this.getClass().getSimpleName());