tools: parsememdump.py support show total pid memory

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2022-04-13 17:13:41 +08:00 committed by GUIDINGLI
parent eca4951021
commit 984208f6a2

17
tools/parsememdump.py Executable file → Normal file
View File

@ -115,10 +115,27 @@ if __name__ == "__main__":
list.sort(key=lambda x: x.cnt, reverse=True) list.sort(key=lambda x: x.cnt, reverse=True)
log = log_output(args) 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") log.output("cnt size pid addr mem\n")
for t in list: for t in list:
memstr = "" memstr = ""
log.output("%-4d %-6d %-3d %s " % (t.cnt, t.size, t.pid, t.addr)) log.output("%-4d %-6d %-3d %s " % (t.cnt, t.size, t.pid, t.addr))
if t.mem == []:
continue
for mem in t.mem: for mem in t.mem:
log.output("%s " % mem) log.output("%s " % mem)
memstr += mem + " " memstr += mem + " "