Technical article 111485

How do I calculate the memory used by an SCO OpenServer process?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6

Written · Last revised

Problem

How do I determine how much memory is used by the first and subsequent invocations of a program? The example output for the crash(ADM) region command in Appendix D of the System Administration Guide looks different from what I see on my own system, and I can no longer tell whether some regions are private or shared text. (To access this Appendix, point your browser at the following URL. If your browser is not running on an OpenServer system, then substitute the fully qualified domain name of a remote OpenServer host, such as osr5doc.sco.com, for "localhost":)

http://localhost:457//OSAdminG/det_proc_size.html

Solution

The following crash session shows memory usage for the OpenServer login(M) command:

# crash
dumpfile /dev/mem, namelist = /unix, outfile = stdout

The next command displays the process slot (first field) for each login process. As there are a number of login processes on the system used here, only one is shown below:

> proc | grep login
.
.
366 s 20303 20302 20303     0  73   0 proc+0x1ebd0     login          load
.

The pregion command (the abbreviated form is used here) shows which regions are attached to this process:

> preg 366
SLOT       PREG REG#      REGVA  TYPE FLAGS
366        0    2321  0x8046000 stack rd wr cm
           1    1123  0x8048000  text rd ex cm
           2     935  0x8056000  data rd wr cm
           3    2401 0x80001000 lbtxt rd ex pr wa
           4    2451 0x80054000 lbdat rd wr ex pr wa
           5    3598 0x8005f000 lbtxt rd ex pr wa
           6     907 0x80089000 lbdat rd wr ex pr wa
           7    1966 0x80092000 lbtxt rd ex pr wa
           8    3042 0x800c7000 lbdat rd wr ex pr wa

This region command prints the region table entries for the above:

> reg 2321 1123 935 2401 2451 3598 907 1966 3042 REGION TABLE SIZE = 3754 Region-list:

SLOT  PGSZ VALID  SMEM NONE SOFF  REF SWP NSW FORW BACK INOX TYPE FLAGS
2321     2     2     2    0   70    1   0   0 1965  905   -  priv nosh stack
1123    14    14     0    0   72    1   0   0 1382  935  481 stxt nosh nosmem
935     18    18    18    0   86    1   0   0 1123 1474  481 priv nosh
2401    83    66     0    0    1    1   0   0 1861 2451   20 map  nosh nosmem
2451    10    10     9    0   84    1   0   0 2401 2426   20 map  nosh
3598    42    36     0    0   95    1   0   0 2684  907   16 map  nosh nosmem
907      8     8     6    0  137    1   0   0 3598 3233   16 map  nosh
1966    53    42     0    0  146    1   0   0  674 3042   14 map  nosh nosmem
3042    10     8     6    0  199    1   0   0 1966 2669   14 map  nosh

The VALID column refers to the number of 4KB pages actually residing in memory. The pages corresponding to the regions shown as lbtxt in the pregion output (slots 2401, 3598 and 1966) are typically shared among many other processes, however. It would therefore be inaccurate to attribute them just to the login process (in this instance the libraries happen to be libprot, libsocket and libc).

To calculate the memory used by the first instance of the login program, sum the entries in the VALID column, excluding the lbtxt ones. This gives 2+14+18+10+8+8 = 60 pages = 240KB.

The SMEM column shows how many non-shared pages are being used by the process. It therefore excludes the lbtxt regions, as well as login's own .text region (corresponding to the actual login program code, as this is automatically shared by subsequent login processes).

The SMEM and VALID columns also differ in the rows corresponding to regions labeled "lbdat" in the pregion output (and labeled as TYPE/FLAGS = map nosh in the region output), by 1+2+2 pages = 20KB. This difference corresponds to read/write shared data which has never been written to, and therefore is shareable among all login processes. For example, region #907 is 8 pages long (PGSZ), 8 of which are VALID, and 6 of which are SMEM (have been copied-on-write and become private, as a result of having been written to by this process).

To calculate the memory used by second and subsequent login processes, sum the entries in the SMEM column. The result is 41 pages = 164 KB.

To summarize, we have learned that on the test system, login consumes 240KB of memory for the first instance and 164KB each for additional processes.

NOTE:     Prior to the introduction of ELF binaries in OpenServer 5.0.0, the
          TYPE column always indicated whether a region is private or shared
          (which is still the case for COFF binaries in OpenServer 5.0.0
          onwards). However, ELF binaries now result in entries labeled
          "map" (as shared objects are mapped into the process's address
          space with mmap(S)), so the above method needs to be used to
          determine whether a region is private or shared.

In OpenServer 5.0.6, login(M) starts the user's shell (specified in /etc/passwd) with exec(S). There is no longer a persistent login process associated with each logged-in user.

See also

System Administration Guide Appendix D, "Using the crash(ADM) diagnostic tool"

From the Xinuos technical article database, record 111485. Reproduced with permission. The original is at www.sco.com/ta/111485, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.