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

Commit 378aaa05 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Avoid subtracting shmem twice when calculating LOST RAM." into main

parents 37a69f3f 7031a84e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -87,6 +87,13 @@ public final class MemInfoReader {
        return mInfos[Debug.MEMINFO_FREE];
    }

    /**
     * Amount of RAM that used by shared memory (shmem) and tmpfs
     */
    public long getShmemSizeKb() {
        return mInfos[Debug.MEMINFO_SHMEM];
    }

    /**
     * Amount of RAM that the kernel is being used for caches, not counting caches
     * that are mapped in to processes.
+4 −0
Original line number Diff line number Diff line
@@ -13143,6 +13143,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            final long lostRAM = memInfo.getTotalSizeKb()
                    - (ss[INDEX_TOTAL_PSS] - ss[INDEX_TOTAL_SWAP_PSS])
                    - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                    // NR_SHMEM is subtracted twice (getCachedSizeKb() and getKernelUsedSizeKb())
                    + memInfo.getShmemSizeKb()
                    - kernelUsed - memInfo.getZramTotalSizeKb();
            if (!opts.isCompact) {
                pw.print(" Used RAM: "); pw.print(stringifyKBSize(ss[INDEX_TOTAL_PSS] - cachedPss
@@ -13656,6 +13658,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            long lostRAM = memInfo.getTotalSizeKb()
                    - (ss[INDEX_TOTAL_PSS] - ss[INDEX_TOTAL_SWAP_PSS])
                    - memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
                    // NR_SHMEM is subtracted twice (getCachedSizeKb() and getKernelUsedSizeKb())
                    + memInfo.getShmemSizeKb()
                    - memInfo.getKernelUsedSizeKb() - memInfo.getZramTotalSizeKb();
            proto.write(MemInfoDumpProto.USED_PSS_KB, ss[INDEX_TOTAL_PSS] - cachedPss);
            proto.write(MemInfoDumpProto.USED_KERNEL_KB, memInfo.getKernelUsedSizeKb());