26

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)

I want to do the same thing in 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?

1

2 Answers 2

71

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

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

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

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 
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much for your perfect answer!!
Just in case someone wonders: it's in bytes, unlike on Linux which uses kilobytes.
5

For me, the next command works great:

ps -axm -o %mem,rss,comm | grep <programm name> 

2 Comments

Also, you can grep whatever you need, f.e. PID
For process specific details ps -xm -o %mem,rss,comm -p $(pgrep <process-name>) for instance ps -xm -o %mem,rss,comm -p $(pgrep InDesign)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.