Table of Contents

On Linux, the top command gives you several different numbers for memory. Here's what it says about the Hello World example:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2120 root      20   0 4373m  15m 7152 S    0  0.2   0:00.10 java

VIRT

is the virtual memory space: the sum of everything in the virtual memory map (see below). It is largely meaningless, except when it isn't (see below).

RES

is the resident set size: the number of pages that are currently resident in RAM. In almost all cases, this is the only number that you should use when saying “too big.” But it's still not a very good number, especially when talking about Java.

SHR

is the amount of resident memory that is shared with other processes. For a Java process, this is typically limited to shared libraries and memory-mapped JARfiles.