- 论坛徽章:
- 1
|
用crash可以查看,比如查看login进程占用的内存:
原文见:
http://wdb1.sco.com/kb/showta?ta ... 3893943&pgnum=1
# 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 (查看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.
[ 本帖最后由 CNL 于 2005-12-19 11:10 编辑 ] |
|