I'm running Mac OS 10.6. I want to run top
to get memory usage, but not in interactive mode, or any mode that updates. I just want memory usage at that point in time then return to prompt. I've looked for other utilities to get memory usage... but came up short (vm_stat
is for virtual memory). Can someone direct me how to get top
or something else to print memory usage to stdout?
By default, top doesn't display processes in order of memory usage. It's easy to re-order the menu by using the key combination Shift + M. This will refresh the list with the %MEM column showing memory usage in descending order.
Use ps Command to Find Top Processes by Memory and CPU Usage You can use the ps command with –sort argument to sort the output by memory and CPU usage.
Open shell to run top command, if we run top it will display only command name of the running process, to see full command we use -c option with top. Then press SHIFT + m from the keyboard to sort by memory usage.
Go about your work as normal, and if the computer begins to slow down, press Ctrl+Shift+Esc to bring up Windows Task Manager. Click the Performance tab and select Memory in the sidebar to see a graph of your current RAM usage.
top -l 1
will put just one sample to standard output (you can redirect it, filter it, etc, as you wish of course). man top
for many more details.
you can also use the ps
command. eg
ps -eo pmem,comm
check the ps
man page for more output formatting. eg rss, size etc..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With