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

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?


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).