How can I monitor memory usage of a process running from the terminal in OSX

62,693

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.

Screenshot

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}'
Share:
62,693

Related videos on Youtube

codecowboy
Author by

codecowboy

Stackoverflow is my rubber duck.

Updated on September 18, 2022

Comments

  • codecowboy
    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
    HikeMike over 10 years
    He doesn't seem to know the process name. Otherwise it'd show up in Activity Monitor.
  • abzcoding
    abzcoding over 10 years
    sorry i did not expect that one!
  • kenorb
    kenorb almost 9 years
    Version with the name in the front: top -l 1 | grep "FOO" | awk '{print "NAME="$2 " MEM="$9 "\tRPRVT="$10}'.
  • Thatkookooguy
    Thatkookooguy about 8 years
    can you please mention in your answer if this also works on OSX since the OP asked about OSX specifically?
  • Jay
    Jay almost 8 years
    Yes it does work!
  • Thatkookooguy
    Thatkookooguy almost 8 years
    I asked that you'll add it in your answer since the original poster asked about OS X specifically.
  • Gianfranco P.
    Gianfranco P. about 4 years
    This 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 ;}'