Merge "Fix a memory leak in UidState." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
42b71cc155
@@ -150,6 +150,7 @@ public final class UidState {
|
|||||||
public void resetSafely(long now) {
|
public void resetSafely(long now) {
|
||||||
mDurations.resetTable();
|
mDurations.resetTable();
|
||||||
mStartTime = now;
|
mStartTime = now;
|
||||||
|
mProcesses.removeIf(p -> !p.isInUse());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -186,4 +186,19 @@ public class ProcessStatsTest extends TestCase {
|
|||||||
eq(0),
|
eq(0),
|
||||||
eq(APP_1_PROCESS_NAME));
|
eq(APP_1_PROCESS_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testSafelyResetClearsProcessInUidState() throws Exception {
|
||||||
|
ProcessStats processStats = new ProcessStats();
|
||||||
|
ProcessState processState =
|
||||||
|
processStats.getProcessStateLocked(
|
||||||
|
APP_1_PACKAGE_NAME, APP_1_UID, APP_1_VERSION, APP_1_PROCESS_NAME);
|
||||||
|
processState.makeActive();
|
||||||
|
UidState uidState = processStats.mUidStates.get(APP_1_UID);
|
||||||
|
assertTrue(uidState.isInUse());
|
||||||
|
processState.makeInactive();
|
||||||
|
uidState.resetSafely(NOW_MS);
|
||||||
|
processState.makeActive();
|
||||||
|
assertFalse(uidState.isInUse());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user