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?

2

5 Answers

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.

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

1

You can use this command for monitoring usage of PROCESSNAME:

top -l 1 | grep "PROCESSNAME" | awk '{print "MEM="$9 "\tRPRVT="$10}'
3

You can run the same program, but forwarding x11.

This means you'll get the physical window open up on your desktop from which you're SSHing in from - It's much nicer in terms of visualisation

Here's a tutorial on how to set up x11. It's really simple to do, and it's much nicer. (plus it's useful for running graphical installer wizards too!)

EDIT: Here's an example I've screenshotted for you of me SSHing in with X11 forwarding(putty) from my Windows machine to my Linux machine, then starting up my system monitor Ksysguard. As you can see the whole window appears as it would do if you were on the actual machine. Capture of SSH and X11

Image of process manager running via x11

3
top -l 1 | grep -E "^CPU|^Phys"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like