[英]How to get the memory usage of a OS X/macOS process
In Ubuntu, /usr/bin/time -v any-command
tells me the memory usage of any-command
and some information. 在Ubuntu中,
/usr/bin/time -v any-command
告诉我any-command
和一些信息的内存使用情况。 (Source: https://stackoverflow.com/a/774601/2885946 ) (来源: https : //stackoverflow.com/a/774601/2885946 )
I want to do the same thing in OS X/macOS. 我想在OS X / macOS中做同样的事情。
Could you tell me how to get the memory usage of a process on OS X like /usr/bin/time -v
in Ubuntu? 你能告诉我如何在OS X上获取一个进程的内存使用情况,比如Ubuntu中的
/usr/bin/time -v
吗?
You can use the Apple-supplied /usr/bin/time
as follows without installing anything: 您可以按如下方式使用Apple提供的
/usr/bin/time
而无需安装任何内容:
/usr/bin/time -l <DO SOMETHING>
Sample Output 样本输出
0.04 real
0.00 user
0.00 sys
2830336 maximum resident set size <-- peak memory usage
0 average shared memory size
0 average unshared data size
0 average unshared stack size
462 page reclaims
253 page faults
0 swaps
13 block input operations
3 block output operations
0 messages sent
0 messages received
0 signals received
26 voluntary context switches
94 involuntary context switches
对我来说,下一个命令效果很好:
ps -axm -o %mem,rss,comm | grep <programm name>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.