From 984208f6a275c67058b0fc44407925fc4bd33291 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Wed, 13 Apr 2022 17:13:41 +0800 Subject: [PATCH] tools: parsememdump.py support show total pid memory Signed-off-by: anjiahao --- tools/parsememdump.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) mode change 100755 => 100644 tools/parsememdump.py diff --git a/tools/parsememdump.py b/tools/parsememdump.py old mode 100755 new mode 100644 index 1c8d4eeec8..ecb3b99d35 --- a/tools/parsememdump.py +++ b/tools/parsememdump.py @@ -115,10 +115,27 @@ if __name__ == "__main__": list.sort(key=lambda x: x.cnt, reverse=True) log = log_output(args) + total_dir = {} + for t in list: + if t.pid in total_dir: + total_dir[t.pid] += t.size + else: + total_dir.setdefault(t.pid, t.size) + + log.output("total memory used for ervey pid\n") + log.output("pid total size\n") + total_size = 0 + for pid, size in sorted(total_dir.items(), key=lambda x: x[1]): + log.output("%-3d %-6d\n" % (pid, size)) + total_size += size + log.output("all used memory %-6d\n" % (total_size)) + log.output("cnt size pid addr mem\n") for t in list: memstr = "" log.output("%-4d %-6d %-3d %s " % (t.cnt, t.size, t.pid, t.addr)) + if t.mem == []: + continue for mem in t.mem: log.output("%s " % mem) memstr += mem + " "