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.


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.

  • 1
    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

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