[英]Detailed RAM report and usage of running program on linux
I would like to know how to monitor a specific program (with its pid) and get a report of it's RAM used, like with perf record -p <PID> sleep 15 && perf report
, giving me instruction using the most of the memory.我想知道如何监视特定程序(及其 pid)并获取其使用的 RAM 的报告,例如使用perf record -p <PID> sleep 15 && perf report
,给我使用大部分 memory 的指令。 I already heard about top commands, but it is not what I want.我已经听说过顶级命令,但这不是我想要的。
Massif is a heap profiler included in the valgrind suite, and can provide some of this information. Massif是包含在 valgrind 套件中的堆分析器,可以提供其中的一些信息。
Start it with valgrind --tool=massif <you program>
.使用valgrind --tool=massif <you program>
启动它。 This will create a massif.out file that contains various "snapshots" of heap memory usage while the program ran.这将创建一个 massif.out 文件,其中包含程序运行时堆 memory 使用的各种“快照”。 A simpler viewer ms_print
is included and will dump all the snapshots with stack traces.包含一个更简单的查看器ms_print
,它将转储所有带有堆栈跟踪的快照。
For example:例如:
83.83% (10,476B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->30.03% (3,752B) 0x4E6079B: _nl_make_l10nflist (l10nflist.c:241)
| ->24.20% (3,024B) 0x4E608E7: _nl_make_l10nflist (l10nflist.c:285)
| | ->12.10% (1,512B) 0x4E5A091: _nl_find_locale (findlocale.c:218)
| | | ->12.10% (1,512B) 0x4E5978B: setlocale (setlocale.c:340)
| | | ->12.10% (1,512B) 0x4016BA: main (sleep.c:106)
| | |
| | ->12.10% (1,512B) 0x4E608E7: _nl_make_l10nflist (l10nflist.c:285)
| | ->09.41% (1,176B) 0x4E5A091: _nl_find_locale (findlocale.c:218)
| | | ->09.41% (1,176B) 0x4E5978B: setlocale (setlocale.c:340)
| | | ->09.41% (1,176B) 0x4016BA: main (sleep.c:106)
| | |
| | ->02.69% (336B) 0x4E608E7: _nl_make_l10nflist (l10nflist.c:285)
| | ->02.69% (336B) 0x4E5A091: _nl_find_locale (findlocale.c:218)
| | ->02.69% (336B) 0x4E5978B: setlocale (setlocale.c:340)
| | ->02.69% (336B) 0x4016BA: main (sleep.c:106)
| |
| ->05.83% (728B) 0x4E5A091: _nl_find_locale (findlocale.c:218)
| ->05.83% (728B) 0x4E5978B: setlocale (setlocale.c:340)
| ->05.83% (728B) 0x4016BA: main (sleep.c:106)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.