RAM and Virtual Memory: top

top shows an ordered list of running processes. Default ordering is by CPU usage. The following options can be chosen during runtime to display memory-specific information.
  • M: Sorts tasks by resident set size, which is the amount of memory they are using (rather than the amount of memory they have asked for).
  • m: toggles whether information about system memory usage will be shown on the screen

Performance Diagnosis
Technical articles
The two modes of top

Two modes of options can be used to modify how top displays its information
  • command line
  • runtime options

Command Line
The command line options are:
top [d delay] [C] [H] [i] [n iter] [b]

Description of top's command line options:
  • d delay: delay between statistics update
  • C: display the summed CPU statistics
  • H: show the individual threads rather than just displaying a total for each application
  • i: do not display processes that aren't using any of the CPU
  • n iter: number of iterations before exiting
  • b: batch mode, useful if redirecting output to a file or another command. Will not accept input and runs until the iterations limit set with the  -n command-line option or until killed.
  • p: Monitor only processes with specified process IDs.  Option can be given up to 20 times as -pN1 -pN2 ..., or provide a comma delimited list with up to 20 pids such as -pN1,N2,N3.  Co-mingling both approaches is permitted.

Runtime Options
The output of top can be easily customized during runtime. Some options are:
  • A: will switch between full-screen mode and alternate-display mode. The alternate-display mode has a lot of options that are worth experimenting with.
  • f: Fields-Management, display a separate screen where you can change which fields are displayed, their order and also designate the sort field.

Statistics Provided

The following Memory-related process level performance statistics are displayed by top:
  • RES: anything belonging to the process that is occupying physical memory
  • %MEM - simply RES divided by total physical memory
  • CODE: the total amount of physical memory in K that the process's executable code is using
  • DATA: the total amount of physical memory in K that the process's data and stack is using
  • SHR: subset of RES that can be shared with other processes
  • SWAP: amount of swap in K that the process is using
  • USED: the sum of RES and SWAP
  • VIRT: everything in-use and/or reserved

Performance Diagnosis
Technical articles