Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use htop to watch my processes, but most of services ran are multi threaded, so they are shown on several lines with a % of memory use which in some cases is the same for all, sometimes it varies among them.

Say in the case of Firefox it can list 15 processes each consuming 13% of memory.

Can I know hoc much memory is Firefox, MySQL, some fcgi script or anything is consuming? since the htop output seems misleading.

share|improve this question
up vote 6 down vote accepted

Most top implementations have a way to turn the display of threads on or off.

  • htop: in the “Setup / Display options” menu, “Hide userlands threads”.
  • Linux top: press H to toggle the showing of threads (but they're off by default).
  • OpenBSD top: press T to toggle the showing of threads (but they're off by default).

Note that memory mappings, and hence memory occupation, is a property of a process, so you'll always see the same numbers for every thread in a process. If you see different numbers, it means there are multiple processes.

There's no easy way to find out the total memory consumption of a set of processes because the concept isn't well-defined. Some of the memory may be shared; this happens all the time with shared libraries, and in addition related processes (such as multiple instances of a server) are more likely to use shared memory to exchange data. If you just add the figures, you'll often get a number that's a lot larger than the actual used memory.

share|improve this answer
I didn't realize that the process' memory concept isn't well defined, I think that's what makes it all have more sense. Thanks – Jjdelc Jan 10 '11 at 6:00

You could use this: http://www.pixelbeat.org/scripts/ps_mem.py

share|improve this answer
why use that? why is it better than the standard tools? – Tshepang Jan 12 '11 at 0:53
It counts shared memory only once. – GDR Jan 18 '11 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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