AIX进程内存占用数的计算

 
今天,我们来分析下AIX下进程内存占用。
 
AIX  man ps 提示"RSS   (v flag) The real-memory (resident set) size of the process (in 1KB units)."
但与linux一样,RSS并不是进程实际占用物理内存的大小。
 
下面是IBM官方的详细解释:
RSS:
Real-memory (resident set) size in kilobytes of the process. This number is equal to the sum of the number of working segment and code segment pages in memory times 4. Remember that code segment pages are shared among all of the currently running instances of the program  
TRS : Size of the resident set (real memory) of text. This is the number of code segment pages times 4. This number exaggerates memory use for programs of which multiple instances are running.
 
 
见下面命令:
[oracle@gxtest] $ps axv |head -1;ps axv | grep oracle | head -10

      PID    TTY STAT  TIME PGIN  SIZE   RSS   LIM  TSIZ   TRS %CPU %MEM COMMAND
    33118      - A     0:00    0  8436 106112    xx 88895 97676  0.0  0.0 oracle
   946452      - A     0:00    0  8436 106112    xx 88895 97676  0.0  0.0 oracle
  1360266      - A     0:00    0  8436 106112    xx 88895 97676  0.0  0.0 oracle
  1970596      - A     0:00    0  8440 106116    xx 88895 97676  0.0  0.0 oracle
  2838910      - A     0:00    0  8424 106100    xx 88895 97676  0.0  0.0 oracle
  2949614      - A     0:00    0  9372 107048    xx 88895 97676  0.0  0.0 oracle
  2970004      - A     0:16    0  9028 106704    xx 88895 97676  0.1  0.0 oracle
...
 
上面所有oracle的进程trs都为97676,是所有oracle进程共享的,所以他们的trs都一样。
我们可以使用RSS-TRS做为进程的占用内存,实际上RSS-TRS就是SIZE。
 
见SIZE的解释:
SIZE Virtual size (in paging space) in kilobytes of the data section of the process (displayed as SZ by other flags). This number is equal to the number of working segment pages of the process that have been touched times 4. If some working segment pages are currently paged out, this number is larger than the amount of real memory being used. SIZE includes pages in the private segment and the shared-library data segment of the process.  
看上面ps结果中的size对应的数据基本在8m左右,即oracle的server process 占用的物理内存在8m左右。
 
再使用nmon看看:
[root@GXDB1:/]#nmon -r oracle
 
+-topas_nmon--S=WLMsubclasses----Host=GXDB1----------Refresh=2 secs---11:37.14---------------------
| Top-Processes-(4279) ----Mode=3  [1=Basic 2=CPU 3=Perf 4=Size 5=I/O 6=Cmds]----------------------
|  PID       %CPU     Size      Res     Res      Res     Char    RAM      Paging         Command  
|            Used       KB      Set     Text     Data     I/O     Use   io   other repage         
|44564902    94.2   201840   244616   131648   112968        0    0%      0   1832      0 oracle  
|27657376    93.4    94536   137316   131648     5668        4    0%      0      0      0 oracle  
|46924802    82.0    98412   141192   131648     9544        5    0%      0     77      0 oracle  
|16844250    74.4   105400   148180   131648    16532       28    0%      0      0      0 oracle  
|60555840    30.0    95912   138692   131648     7044      892    0%      0      0      0 oracle  
|33686028    28.3   101872   144652   131648    13004       15    0%      0      0      0 oracle  
| 4786076    22.5   105308   148088   131648    16440      399    0%      0      0      0 oracle  
| 7602648    21.3    95816   138596   131648     6948    25055    0%      0      0      0 oracle  
|17236030    20.7    99892   142672   131648    11024       67    0%      0    144      0 oracle  
|26018880    19.0    99056   141836   131648    10188       45    0%      0      0      0 oracle  
|46269150    17.5   129028   126620     3844   122776    18845    0%      0      0      0 extract 
|36110992    16.3   122768   120288     3740   116548    18806    0%      0      0      0 extract 
|46203274    15.8    96684   139464   131648     7816      335    0%      0   4050      0 oracle  
|23069706    15.4    99968   142748   131648    11100       30    0%      0      0      0 oracle
 
上面 Res Set 对应 ps 中的rss;Res Text即为trs;Res Data 即为占用的物理内存。
 
附:
 

Memory usage determination with the ps command

The ps command can also be used to monitor memory usage of individual processes.

The ps v PID command provides the most comprehensive report on memory-related statistics for an individual process, such as:

Page faults Size of working segment that has been touched Size of working segment and code segment in memory Size of text segment Size of resident set Percentage of real memory used by this process
The following is an example:
# ps v
   PID    TTY STAT  TIME PGIN  SIZE   RSS   LIM  TSIZ   TRS %CPU %MEM COMMAND
 36626  pts/3 A     0:00    0   316   408 32768    51    60  0.0  0.0 ps v

The most important columns on the resulting ps report are described as follows:

PGIN Number of page-ins caused by page faults. Since all I/O is classified as page faults, this is basically a measure of I/O volume. SIZE Virtual size (in paging space) in kilobytes of the data section of the process (displayed as SZ by other flags). This number is equal to the number of working segment pages of the process that have been touched times 4. If some working segment pages are currently paged out, this number is larger than the amount of real memory being used. SIZE includes pages in the private segment and the shared-library data segment of the process. RSS Real-memory (resident set) size in kilobytes of the process. This number is equal to the sum of the number of working segment and code segment pages in memory times 4. Remember that code segment pages are shared among all of the currently running instances of the program. If 26 ksh processes are running, only one copy of any given page of the ksh executable program would be in memory, but the ps command would report that code segment size as part of the RSS of each instance of the ksh program. TSIZ Size of text (shared-program) image. This is the size of the text section of the executable file. Pages of the text section of the executable program are only brought into memory when they are touched, that is, branched to or loaded from. This number represents only an upper bound on the amount of text that could be loaded. The TSIZ value does not reflect actual memory usage. This TSIZ value can also be seen by executing the dump -ov command against an executable program (for example, dump -ov /usr/bin/ls). TRS Size of the resident set (real memory) of text. This is the number of code segment pages times 4. This number exaggerates memory use for programs of which multiple instances are running. The TRS value can be higher than the TSIZ value because other pages may be included in the code segment such as the XCOFF header and the loader section. %MEM Calculated as the sum of the number of working segment and code segment pages in memory times 4 (that is, the RSS value), divided by the size of the real memory in use, in the machine in KB, times 100, rounded to the nearest full percentage point. This value attempts to convey the percentage of real memory being used by the process. Unfortunately, like RSS, it tends the exaggerate the cost of a process that is sharing program text with other processes. Further, the rounding to the nearest percentage point causes all of the processes in the system that have RSS values under 0.005 times real memory size to have a %MEM of 0.0.
Note: The ps command does not indicate memory consumed by shared memory segments or memory-mapped segments. Because many applications use shared memory or memory-mapped segments, the svmon command is a better tool to view the memory usage of these segments.
 
 

 

 
 
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/195110/viewspace-764380/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/195110/viewspace-764380/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值