Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a800f9ab authored by Nandana Dutt's avatar Nandana Dutt Committed by Android (Google) Code Review
Browse files

Merge "Fix the lost RAM calculation"

parents a15511e9 786d5453
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -16017,6 +16017,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        updateCpuStatsNow();
        long[] memtrackTmp = new long[1];
        long[] swaptrackTmp = new long[2];
        final List<ProcessCpuTracker.Stats> stats;
        // Get a list of Stats that have vsize > 0
        synchronized (mProcessCpuTracker) {
@@ -16027,12 +16028,13 @@ public class ActivityManagerService extends IActivityManager.Stub
        final int statsCount = stats.size();
        for (int i = 0; i < statsCount; i++) {
            ProcessCpuTracker.Stats st = stats.get(i);
            long pss = Debug.getPss(st.pid, null, memtrackTmp);
            long pss = Debug.getPss(st.pid, swaptrackTmp, memtrackTmp);
            if (pss > 0) {
                if (infoMap.indexOfKey(st.pid) < 0) {
                    ProcessMemInfo mi = new ProcessMemInfo(st.name, st.pid,
                            ProcessList.NATIVE_ADJ, -1, "native", null);
                    mi.pss = pss;
                    mi.swapPss = swaptrackTmp[1];
                    mi.memtrack = memtrackTmp[0];
                    memInfos.add(mi);
                }
@@ -16040,14 +16042,17 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        long totalPss = 0;
        long totalSwapPss = 0;
        long totalMemtrack = 0;
        for (int i=0, N=memInfos.size(); i<N; i++) {
            ProcessMemInfo mi = memInfos.get(i);
            if (mi.pss == 0) {
                mi.pss = Debug.getPss(mi.pid, null, memtrackTmp);
                mi.pss = Debug.getPss(mi.pid, swaptrackTmp, memtrackTmp);
                mi.swapPss = swaptrackTmp[1];
                mi.memtrack = memtrackTmp[0];
            }
            totalPss += mi.pss;
            totalSwapPss += mi.swapPss;
            totalMemtrack += mi.memtrack;
        }
        Collections.sort(memInfos, new Comparator<ProcessMemInfo>() {
@@ -16209,7 +16214,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        memInfoBuilder.append("\n");
        memInfoBuilder.append("  Lost RAM: ");
        memInfoBuilder.append(stringifyKBSize(memInfo.getTotalSizeKb()
                - totalPss - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                - (totalPss - totalSwapPss) - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                - memInfo.getKernelUsedSizeKb() - memInfo.getZramTotalSizeKb()));
        memInfoBuilder.append("\n");
        Slog.i(TAG, "Low on memory:");
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public class ProcessMemInfo {
    final String adjType;
    final String adjReason;
    long pss;
    long swapPss;
    long memtrack;

    public ProcessMemInfo(String _name, int _pid, int _oomAdj, int _procState,