经常有人问到如何在Unix下确定进程消耗的内存资源,以及为何Top工具的显示非常高。
有人说Top的输出不精确,这种说法是不确切的。实际上是Top输出显示的Oracle进程内存使用,包含了SGA部分。这也是SGA的意义所在。
SGA可以被共享,可以被所有进程所访问,在进程的寻址空间里就包含了SGA的大小。
至于如何更为精确的确定进程的内存消耗,本文简要介绍如下(在QuickIO下,你可能无法看到本文描述情况):
1.系统平台及数据库版本
$ uname -a
SunOS billing 5.8 Generic_108528-23 sun4u sparc SUNW,Ultra-4
Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Sun Nov 28 10:48:00 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
PL/SQL Release 9.2.0.4.0 - Production
CORE 9.2.0.3.0 Production
TNS for Solaris: Version 9.2.0.4.0 - Production
NLSRTL Version 9.2.0.4.0 - Production
SQL> show sga
Total System Global Area 253200688 bytes
Fixed Size 731440 bytes
Variable Size 167772160 bytes
Database Buffers 83886080 bytes
Redo Buffers 811008 bytes
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
2.Top输出
$ top
load averages: 0.12, 0.05, 0.04 billing 10:49:52
54 processes: 52 sleeping, 1 stopped, 1 on cpu
CPU states: 99.3% idle, 0.0% user, 0.3% kernel, 0.4% iowait, 0.0% swap
Memory: 2.0G real, 1.2G free, 404M swap in use, 5.1G swap free
PID USERNAME THR PR NCE SIZE RES STATE TIME FLTS CPU COMMAND
10027 oracle 1 58 0 2568K 1680K cpu03 0:00 0 0.09% top
10052 oracle 1 58 0 322M 275M sleep 21:18 0 0.01% oracle
11264 oracle 22 58 0 329M 275M sleep 59:01 0 0.00% oracle
10056 oracle 1 58 0 322M 275M sleep 3:04 0 0.00% oracle
11262 oracle 14 58 0 331M 270M sleep 73:55 0 0.00% oracle
11260 oracle 258 59 0 333M 274M sleep 52:46 0 0.00% oracle
11266 oracle 1 58 0 325M 276M sleep 26:50 0 0.00% oracle
10054 oracle 1 59 0 322M 275M sleep 18:27 0 0.00% oracle
23519 oracle 1 55 0 322M 278M sleep 0:50 0 0.00% oracle
11258 oracle 1 59 0 323M 271M sleep 0:31 0 0.00% oracle
11285 oracle 1 58 0 17.3M 3848K sleep 0:20 0 0.00% tnslsnr
11270 oracle 1 58 0 322M 271M sleep 0:06 0 0.00% oracle
2990 oracle 1 59 0 322M 276M sleep 0:04 0 0.00% oracle
9872 oracle 1 48 0 1880K 1192K sleep 0:00 0 0.00% ksh
23498 oracle 1 58 0 323M 278M sleep 0:00 0 0.00% oracle
3.Pmap输出及进程内存计算
$ ps -ef|grep ora_
oracle 9881 9872 0 10:49:57 pts/2 0:00 grep ora_
oracle 11258 1 0 Jul 19 ? 0:31 ora_pmon_hsbill
oracle 11260 1 0 Jul 19 ? 52:47 ora_dbw0_hsbill
oracle 11262 1 0 Jul 19 ? 73:55 ora_lgwr_hsbill
oracle 11264 1 0 Jul 19 ? 59:01 ora_ckpt_hsbill
oracle 11266 1 0 Jul 19 ? 26:50 ora_smon_hsbill
oracle 11268 1 0 Jul 19 ? 0:00 ora_reco_hsbill
oracle 11270 1 0 Jul 19 ? 0:06 ora_cjq0_hsbill
oracle 10054 1 0 Nov 02 ? 18:27 ora_j001_hsbill
oracle 10052 1 0 Nov 02 ? 21:19 ora_j000_hsbill
oracle 2990 1 0 Nov 25 ? 0:05 ora_j003_hsbill
oracle 10056 1 0 Nov 02 ? 3:04 ora_j002_hsbill
oracle 8879 1 0 09:54:32 ? 0:00 ora_j004_hsbill
$ pmap 11264
11264: ora_ckpt_hsbill
0000000100000000 53824K read/exec /opt/oracle/product/9.2.0/bin/oracle
000000010358E000 872K read/write/exec /opt/oracle/product/9.2.0/bin/oracle
0000000103668000 7968K read/write/exec [ heap ]
0000000380000000 266240K read/write/exec/shared [ ism shmid=0x64 ]
FFFFFFFF7C802000 8K read/write/exec [ anon ]
FFFFFFFF7C814000 8K read/write/exec [ anon ]
FFFFFFFF7C826000 8K read/write/exec [ anon ]
FFFFFFFF7C838000 8K read/write/exec [ anon ]
FFFFFFFF7C84A000 8K read/write/exec [ anon ]
FFFFFFFF7C85C000 8K read/write/exec [ anon ]
FFFFFFFF7C86E000 8K read/write/exec [ anon ]
F