Memory usage by processes

The svmon -P command displays the memory usage statistics for all the processes currently running on a system.

The following is an example of the svmon -P command:
# svmon -P

--------------------------------------------------------------------------------
     Pid Command          Inuse        Pin     Pgsp    Virtual 64-bit Mthrd 16MB
   16264 IBM.ServiceRM    10075       3345     3064      13310      N     Y    N

     PageSize      Inuse        Pin       Pgsp    Virtual
     s   4 KB      10075       3345       3064      13310
     L  16 MB          0          0          0          0

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   f001e         d work shared library text          s   4857     0   36  6823 
       0         0 work kernel seg                   s   4205  3335 2674  5197 
   b83f7         2 work process private              s    898     2  242  1098 
   503ea         f work shared library data          s     63     0   97   165 
   c8439         1 pers code,/dev/hd2:149841         s     28     0    -     - 
   883f1         - work                              s     21     8   14    26 
   e83dd         - pers /dev/hd2:71733               s      2     0    -     - 
   f043e         4 work shared memory segment        s      1     0    1     1 
   c0438         - pers large file /dev/hd9var:243   s      0     0    -     - 
   b8437         3 mmap mapped to sid a03f4          s      0     0    -     - 
   583eb         - pers large file /dev/hd9var:247   s      0     0    -     - 

--------------------------------------------------------------------------------
     Pid Command          Inuse        Pin     Pgsp    Virtual 64-bit Mthrd 16MB
   17032 IBM.CSMAgentR     9791       3347     3167      12944      N     Y    N

     PageSize      Inuse        Pin       Pgsp    Virtual
     s   4 KB       9791       3347       3167      12944
     L  16 MB          0          0          0          0

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   f001e         d work shared library text          s   4857     0   36  6823 
       0         0 work kernel seg                   s   4205  3335 2674  5197 
     400         2 work process private              s    479     2  303   674 
   38407         f work shared library data          s    120     0  127   211 
   a83f5         1 pers code,/dev/hd2:149840         s     99     0    -     - 
   7840f         - work                              s     28    10   27    39 
   e83dd         - pers /dev/hd2:71733               s      2     0    -     - 
   babf7         - pers /dev/hd2:284985              s      1     0    -     - 
   383e7         - pers large file /dev/hd9var:186   s      0     0    -     - 
   e03fc         - pers large file /dev/hd9var:204   s      0     0    -     - 
   f839f         3 mmap mapped to sid 5840b          s      0     0    -     - 
[...]
The command output details both the global memory use per process and also detailed memory use per segment used by each reported process. The default sorting rule is a decreasing sort based on the Inuse page count. You can change the sorting rule using the svmon command with either the -u, -p, -g, or -v flags.

For a summary of the top 15 processes using memory on the system, use the following command:

# svmon -Pt15 | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}'
--------------------------------------------------------------------------------
     Pid Command          Inuse        Pin     Pgsp    Virtual 64-bit Mthrd 16MB
   16264 IBM.ServiceRM    10075       3345     3064      13310      N     Y    N
   17032 IBM.CSMAgentR     9791       3347     3167      12944      N     Y    N
   21980 zsh               9457       3337     2710      12214      N     N    N
   22522 zsh               9456       3337     2710      12213      N     N    N
   13684 getty             9413       3337     2710      12150      N     N    N
   26590 perl5.8.0         9147       3337     2710      12090      N     N    N
    7514 sendmail          9390       3337     2878      12258      N     N    N
   14968 rmcd              9299       3340     3224      12596      N     Y    N
   18940 ksh               9275       3337     2710      12172      N     N    N
   14424 ksh               9270       3337     2710      12169      N     N    N
    4164 errdemon          9248       3337     2916      12255      N     N    N
    3744 cron              9217       3337     2770      12125      N     N    N
   11424 rpc.mountd        9212       3339     2960      12290      N     Y    N
   21564 rlogind           9211       3337     2710      12181      N     N    N
   26704 rlogind           9211       3337     2710      12181      N     N    N

The Pid 16 264 is the process ID that has the highest memory consumption. The Command indicates the command name, in this case IBM®.ServiceRM. The Inuse column, which is the total number of pages in real memory from segments that are used by the process, shows 10 075 pages. Each page is 4 KB. The Pin column, which is the total number of pages pinned from segments that are used by the process, shows 3 345 pages. The Pgsp column, which is the total number of paging-space pages that are used by the process, shows 3 064 pages. The Virtual column (total number of pages in the process virtual space) shows 13 310.

The detailed section displays information about each segment for each process that is shown in the summary section. This includes the virtual, Vsid, and effective, Esid, segment identifiers. The Esid reflects the segment register that is used to access the corresponding pages. The type of the segment is also displayed along with its description that consists in a textual description of the segment, including the volume name and i-node of the file for persistent segments. The report also details the size of the pages the segment is backed by, where s denotes 4 KB pages and L denotes 16 MB pages, the number of pages in RAM, Inuse, number of pinned pages in RAM ,Pin, number of pages in paging space, Pgsp, and number of virtual pages, Virtual.

You can use even more options to obtain more details. The -j option displays the path of the file for persistent segments. The -l option provides more detail for segments and the -r option displays the memory ranges used by each segment. The following is an example of the svmon command with the -l, -r, and -j options:
# svmon -S f001e 400 e83dd -l -r -j

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   f001e         d work shared library text          s   4857     0   36  6823 
                   Addr Range: 0..60123
                   Shared library text segment
     400         2 work process private              s    480     2  303   675 
                   Addr Range: 0..969 : 65305..65535
                   pid(s)=17032
   e83dd         - pers /dev/hd2:71733               s      2     0    -     - 
                        /usr/lib/nls/loc/uconvTable/ISO8859-1                  
                   Addr Range: 0..1
                   pid(s)=17552, 17290, 17032, 16264, 14968, 9620

The Address Range specifies one range for a persistent or client segment and two ranges for a working segment. The range for a persistent or a client segment takes the form '0..x,' where x is the maximum number of virtual pages that have been used. The range field for a working segment can be '0..x : y..65535', where 0..x contains global data and grows upward, and y..65535 contains stack area and grows downward. For the address range, in a working segment, space is allocated starting from both ends and working towards the middle. If the working segment is non-private (kernel or shared library), space is allocated differently.

In the above example, the segment ID 400 is a private working segment; its address range is 0..969 : 65305..65535. The segment ID f001e is a shared library text working segment; its address range is 0..60123.

A segment can be used by multiple processes. Each page in real memory from such a segment is accounted for in the Inuse field for each process using that segment. Thus, the total for Inuse may exceed the total number of pages in real memory. The same is true for the Pgsp and Pin fields. The values displayed in the summary section consist of the sum of Inuse, Pin, and Pgsp, and Virtual counters of all segments used by the process.

In the above example, the e83dd segment is used by several processes whose PIDs are 17552, 17290, 17032, 16264, 14968 and 9620.