I'm copying this from a man page I wrote for plog, since I was trying to make it clear there:
It is important to understand the difference between virtual address
space and physical memory in interpreting some of the above
statistics. As the name implies, virtual address space is not real;
it’s basically a map of all the memory currently allocated to a
process. The limit on the size of this map is the same for each
processes (generally, 2-4 GB), and it is not accumulated (ie, you may
have dozens or hundreds of processes, each with its own 2-4 GB virtual
address space, on a system that only actually has 512 MB of physical
memory).
Data cannot actually be stored or retrieved from virtual address
space; real data requires real, physical memory. It is the kernel’s
job to manage one in relation to another. Virtual space stats
(VirtualSz, Data+Stack, and Priv&Write) are useful for considering the
structure of a process and the relationship to physical memory use,
but with regard to amount of RAM actually used, the physical memory
stats (ResidentSz, Share, and Proportion) are what counts.
Top doesn't quite have all those metrics, but the VIRT score is virtual address space, RES refers to physical memory as does SHR. If you are concerned about relative memory usage (ie, one process compared to another), the RES score is more relevant.
Certain parts of VIRT are relevant relative to other processes; visors such as openVZ limit containers based on the total amount of private writable address space, not RSS. Top doesn't report this, but pmap and plog do (see the plog manpage for "Priv&Write"; this was actually part of my motive when writing it).
NOTE: Assuming you have this version of top
(procps). You can check with this command:
$ top --version
top: procps version 3.2.8
usage: top -hv | -bcisSH -d delay -n iterations [-u user | -U user] -p pid [,pid ...]
procps is often the version of top
included with Fedora/CentOS/RHEL and other variants.
Changing columns
If you look in the man page for top
you'll see a section titled: "2b. SELECTING and ORDERING Columns". There are keyboard shortcuts for toggling visibility for the different fields/columns.
For example:
f,o . Fields/Columns: 'f' add or remove; 'o' change display order
F or O . Select sort field
<,> . Move sort field: '<' next col left; '>' next col right
You can use the key f while in top
to get to a secondary screen where you can specify which columns should be toggled visible or not:
For example:
Current Fields: ANOPQRSTUVbcdefgjlmyzWHIKX for window 3:Mem
Toggle fields via field letter, type any other key to return
* A: PID = Process Id * W: S = Process Status
* N: %MEM = Memory usage (RES) * H: PR = Priority
* O: VIRT = Virtual Image (kb) * I: NI = Nice value
* P: SWAP = Swapped size (kb) * K: %CPU = CPU usage
* Q: RES = Resident size (kb) * X: COMMAND = Command name/line
* R: CODE = Code size (kb)
...
There are more, these are just a sample. When you're done toggling the columns the way you want, use the Esc to get out of the selection screen.
Saving configuration
You can use the Shift+W to save your changes so they're the defaults:
W Write configuration file
The file is stored here, $HOME/.toprc
, and looks like this:
$ more .toprc
RCfile for "top with windows" # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=1.000, Curwin=2
Def fieldscur=AEHIoqTWKNMBcdfgjpLrsuvyzX
winflags=129016, sortindx=19, maxtasks=0
summclr=2, msgsclr=5, headclr=7, taskclr=7
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=63416, sortindx=13, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=65464, sortindx=13, maxtasks=0
summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX
winflags=65464, sortindx=12, maxtasks=0
summclr=3, msgsclr=3, headclr=2, taskclr=7
See section 5 of the man page for more details, "5. FILES".
Best Answer
When prompted for the PID to renice, entering any value that isn't a positive integer will exit the renice mode with an error message. Once you enter a PID, however, you are stuck entering a priority; any invalid entry will cause the get_int function to return -1, which will set the priority to -1. The only way to avoid entering a priority is to kill top. Ctrl-C should work. Ctrl-D or enter will cause the niceness to be set to -1.
Source: Procps source code