What's the easiest way to show memory usage of processes with the same name?

Not individually, but the total usage.

To figure out how much things like Chrome consume memory.


I would select all the process with pgrep, print resident memory with ps and sum it using awk:

ps -p $(pgrep -d, -x chrome) -ho rss | awk '{s+=$1} END {printf "%i", s}'

For some process it's probably better to look for full command line instead of name. On my distribution, using chromium:

ps -p $(pgrep -d, --full /usr/lib/chromium/chromium) -ho rss | awk '{s+=$1} END {printf "%i", s}'
  • running this command gives me error: only one heading option may be specified(from ps). I'm on Gentoo – Hrisip Feb 20 at 18:06
  • Hum, maybe try --no-headers -o rss instead? – kaliko Feb 20 at 19:31
  • ps -p $(pgrep -d, -x chrome) --no-headers -o rss | awk '{s+=$1} END {printf "%i", s}' same. – Hrisip Feb 20 at 19:41
  • Damned, I guess we have different ps implementations or version. What about: ps -p $(pgrep -d, -x chrome) -o rss | awk '$1 ~ /^[0-9]+$/ {s+=$1} END {printf "%i", s}' ? – kaliko Feb 20 at 19:51
  • nah. I guess the problem is that the pgrep command gives output in the following form 3402 chrome,3410 chrome – Hrisip Feb 20 at 19:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.