Fix total memtrack Graphics and GL calculations

Some execution paths do not account memtrack reported Graphics and GL
values in the calculations of memtrack total memory consumption.
Fix this by adding the missing parts.

Bug: 174546244
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I77f06322fbb06ffa33115c1469aba80e59247904
This commit is contained in:
Suren Baghdasaryan
2021-02-23 19:06:48 -08:00
parent c894a9002b
commit 1c5d763107
2 changed files with 10 additions and 4 deletions

View File

@@ -10382,6 +10382,8 @@ public class ActivityManagerService extends IActivityManager.Stub
}
endTime = SystemClock.currentThreadTimeMillis();
hasSwapPss = mi.hasSwappedOutPss;
memtrackGraphics = mi.getOtherPrivate(Debug.MemoryInfo.OTHER_GRAPHICS);
memtrackGl = mi.getOtherPrivate(Debug.MemoryInfo.OTHER_GL);
} else {
reportType = ProcessStats.ADD_PSS_EXTERNAL;
startTime = SystemClock.currentThreadTimeMillis();
@@ -10533,6 +10535,8 @@ public class ActivityManagerService extends IActivityManager.Stub
if (!Debug.getMemoryInfo(st.pid, info)) {
return;
}
memtrackGraphics = info.getOtherPrivate(Debug.MemoryInfo.OTHER_GRAPHICS);
memtrackGl = info.getOtherPrivate(Debug.MemoryInfo.OTHER_GL);
} else {
long pss = Debug.getPss(st.pid, tmpLong, memtrackTmp);
if (pss == 0) {

View File

@@ -1327,6 +1327,8 @@ public class AppProfiler {
// Get a list of Stats that have vsize > 0
final List<ProcessCpuTracker.Stats> stats = getCpuStats(st -> st.vsize > 0);
final int statsCount = stats.size();
long totalMemtrackGraphics = 0;
long totalMemtrackGl = 0;
for (int i = 0; i < statsCount; i++) {
ProcessCpuTracker.Stats st = stats.get(i);
long pss = Debug.getPss(st.pid, swaptrackTmp, memtrackTmp);
@@ -1337,6 +1339,8 @@ public class AppProfiler {
mi.pss = pss;
mi.swapPss = swaptrackTmp[1];
mi.memtrack = memtrackTmp[0];
totalMemtrackGraphics += memtrackTmp[1];
totalMemtrackGl += memtrackTmp[2];
memInfos.add(mi);
}
}
@@ -1345,20 +1349,18 @@ public class AppProfiler {
long totalPss = 0;
long totalSwapPss = 0;
long totalMemtrack = 0;
long totalMemtrackGraphics = 0;
long totalMemtrackGl = 0;
for (int i = 0, size = memInfos.size(); i < size; i++) {
ProcessMemInfo mi = memInfos.get(i);
if (mi.pss == 0) {
mi.pss = Debug.getPss(mi.pid, swaptrackTmp, memtrackTmp);
mi.swapPss = swaptrackTmp[1];
mi.memtrack = memtrackTmp[0];
totalMemtrackGraphics += memtrackTmp[1];
totalMemtrackGl += memtrackTmp[2];
}
totalPss += mi.pss;
totalSwapPss += mi.swapPss;
totalMemtrack += mi.memtrack;
totalMemtrackGraphics += memtrackTmp[1];
totalMemtrackGl += memtrackTmp[2];
}
Collections.sort(memInfos, new Comparator<ProcessMemInfo>() {
@Override public int compare(ProcessMemInfo lhs, ProcessMemInfo rhs) {