Command organises ps output by rss
\\
RSS stands for Resident Set Size
\\
This is a actual number in kilobytes of how much RAM the current process is using.
ps -Fe --sort:-rss
ps -Fe --sort:-rss | head -11
\\
Find the ram usage of a specific service:
ps --no-headers -o "rss,cmd" -C httpd | awk '{ sum+=$1 }
END { printf ("\nRAM statistics\n--------------\n") }
END { printf ("Total RAM: %d%s\n", sum/1024, "M") }
END { printf ("Total processes: %d\n", NR) }
END { printf ("Average RAM/process: %d%s\n", sum/NR/1024, "M\n") }'
\\
\\
Description
-e = select all processes
-F = full format
--sort:-rss = sort the results by resident set size (real memory size in bytes)
\\
\\
Once you have the output of the command you will need to investigate the processes 'State'
^ State ^ Definition ^
| D | uninterruptible sleep (usually IO) |
| R | running or runnable (on run queue) |
| S | interruptible sleep (waiting for an event to complete) |
| T | stopped, either by a job control signal or because it is being traced |
| X | dead (should never be seen) |
| Z | defunct ("zombie") process, terminated but not reaped by its parent |
| | |
| < | high-priority (not nice to other users) |
| N | low-priority (nice to other users) |
| L | has pages locked into memory (for real-time and custom IO) |
| s | is a session leader |
| l | is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) |
| + | is in the foreground process group |