• Immutable Page
  • Info
  • Attachments


The kernel keeps a count of how much memory each process uses in two ways, RSS (resident set size) and "virtual size". For our purposes here, "virtual memory used" is the same as "virtual address space used", meaning "how much area in the virtual address space is consumed." On a 32-bit process, there is usually 3GB of total virtual address space available. If you mmap() a 1GB file, you use 1GB of virtual memory, even if that file has not been touched or a single byte of it read into the virtual address space. Note that you could theoretically have 1,000 processess each mapping a 1GB file on a machine with 16MB of RAM, and each consuming 1GB of virtual memory. No _actual_ physical memory gets consumed by consuming virtual memory. Once you start touching that memory area, the file is read in from disk, and you start to consume physical memory (and your RSS goes up).

However, simply knowing the "virtual memory used" and the RSS are not enough to estimate a process's impact on the system. Memory can be shared among processes in several ways. This means that a single physical page may be accounted for as RSS in more than one process. Because of this, the sum of all the processes' RSS on the entire system can actually be greater than the amount of physical RAM in the system.

Some operating systems refer to "virtual memory" in another way.

Tell others about this page:

last edited 2007-09-12 18:08:21 by DaveHansen