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

Commit 0b619cda authored by Eric Miao's avatar Eric Miao
Browse files

Report memory snapshot only when read info successfully from procfs

Although rare, there is a chance reading memory snapshot from procfs
could fail due to not able to open/parse file `/proc/self/status` in
`ProcfsMemoryUtil.readMemorySnapshotFromProcefs()`.

This CL checks the result and only report post-gc memory snapshot
when the result is valid.

Bug: 443751950
Flag: EXEMPT bugfix
Change-Id: I42a6fdea8e8765d5490770daf90510064632fb1d
parent ff09c42b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public class MetricsLoggerWrapper {
        }

        ProcfsMemoryUtil.MemorySnapshot m = ProcfsMemoryUtil.readMemorySnapshotFromProcfs();
        if (m != null) {
            int oom_score_adj = ProcfsMemoryUtil.readOomScoreAdjFromProcfs();
            Runtime runtime = Runtime.getRuntime();
            FrameworkStatsLog.write(FrameworkStatsLog.POSTGC_MEMORY_SNAPSHOT,
@@ -103,3 +104,4 @@ public class MetricsLoggerWrapper {
                runtime.maxMemory());
        }
    }
}