如何获取 OS X/macOS 进程的内存使用情况 [英] How to get the memory usage of a OS X/macOS process

查看:34
本文介绍了如何获取 OS X/macOS 进程的内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Ubuntu 中,/usr/bin/time -v any-command 告诉我 any-command 的内存使用情况和一些信息.(来源:https://stackoverflow.com/a/774601/2885946)

In Ubuntu, /usr/bin/time -v any-command tells me the memory usage of any-command and some information. (Source: https://stackoverflow.com/a/774601/2885946)

我想在 OS X/macOS 中做同样的事情.

I want to do the same thing in OS X/macOS.

您能告诉我如何在 OS X 上获取进程的内存使用情况,例如 Ubuntu 中的 /usr/bin/time -v?

Could you tell me how to get the memory usage of a process on OS X like /usr/bin/time -v in Ubuntu?

推荐答案

你可以使用苹果提供的/usr/bin/time如下,无需安装任何东西:

You can use the Apple-supplied /usr/bin/time as follows without installing anything:

/usr/bin/time -l <DO SOMETHING>

使用完整路径/usr/bin/time很重要,因为time调用bash会报错:-bash: -l: command没找到

It is important to use the full path /usr/bin/time because time calls bash and results in error: -bash: -l: command not found

样本输出

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

这篇关于如何获取 OS X/macOS 进程的内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆