How can I monitor memory usage of a process running from the terminal in OSX
Solution 1
In Activity Monitor, you can view the list of processes hierarchically, to easily find any processes started from Terminal. Just select All Processes, Hierarchically in the toolbar.
For the tool in question, I'd expect the processes to be called phantomjs
or slimerjs
based on the Python launcher.
Solution 2
You can use ps
for that, for example:
ps x -o rss,vsz,command | grep FooProcess
then sort by the real memory (resident set) size of the process using (sort -nr
).
Solution 3
You can use this command for monitoring usage of PROCESSNAME
:
top -l 1 | grep "PROCESSNAME" | awk '{print "MEM="$9 "\tRPRVT="$10}'
Related videos on Youtube
Comments
-
codecowboy almost 2 years
I am running a command line utility called casperJS (installed via node npm) from the OSX terminal. It's a long running process and I'd like to see how much memory it is using, together with any subprocesses.
I don't see the process in Activity Monitor so how I can tell how much memory it is using?
-
HikeMike over 10 yearsHe doesn't seem to know the process name. Otherwise it'd show up in Activity Monitor.
-
abzcoding over 10 yearssorry i did not expect that one!
-
kenorb almost 9 yearsVersion with the name in the front:
top -l 1 | grep "FOO" | awk '{print "NAME="$2 " MEM="$9 "\tRPRVT="$10}'
. -
Thatkookooguy about 8 yearscan you please mention in your answer if this also works on OSX since the OP asked about OSX specifically?
-
Jay almost 8 yearsYes it does work!
-
Thatkookooguy almost 8 yearsI asked that you'll add it in your answer since the original poster asked about OS X specifically.
-
Gianfranco P. about 4 yearsThis will print the memory in MB instead of kb
ps x -o rss,vsz,command | awk 'NR>1 {$1=int($1/1024)"M"; $2=int($2/1024)"M";}{ print ;}'