经常有人问到如何在Unix下确定进程消耗的内存资源以及为何Top工具的显示非常高
有人说Top的输出不精确这种说法是不确切的实际上是Top输出显示的Oracle进程内存使用包含了SGA部分这也是SGA的意义所在
SGA可以被共享可以被所有进程所访问在进程的寻址空间里就包含了SGA的大小
至于如何更为精确的确定进程的内存消耗本文简要介绍如下(在QuickIO下你可能无法看到本文描述情况)
系统平台及数据库版本
$ uname a
SunOS billing Generic_ sunu sparc SUNWUltra
Sun Microsystems Inc SunOS Generic Patch October
$ sqlplus / as sysdba
SQL*Plus: Release Production on Sun Nov ::
Copyright (c) Oracle Corporation All rights reserved
Connected to:
Oraclei Enterprise Edition Release bit Production
With the Partitioning OLAP and Oracle Data Mining options
JServer Release Production
SQL> select * from v$version;
BANNER
Oraclei Enterprise Edition Release bit Production
PL/SQL Release Production
CORE Production
TNS for Solaris: Version Production
NLSRTL Version Production
SQL> show sga
Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
SQL> exit
Disconnected from Oraclei Enterprise Edition Release bit Production
With the Partitioning OLAP and Oracle Data Mining options
JServer Release Production
Top输出
$ top
load averages: billing ::
processes: sleeping stopped on cpu
CPU states: % idle % user % kernel % iowait % swap
Memory: G real G free M swap in use G swap free
PID USERNAME THR PR NCE SIZE RES STATE TIME FLTS CPU COMMAND
oracle K K cpu : % top
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle M K sleep : % tnslsnr
oracle M M sleep : % oracle
oracle M M sleep : % oracle
oracle K K sleep : % ksh
oracle M M sleep : % oracle
Pmap输出及进程内存计算
$ ps ef|grep ora_
oracle :: pts/ : grep ora_
oracle Jul ? : ora_pmon_hsbill
oracle Jul ? : ora_dbw_hsbill
oracle Jul ? : ora_lgwr_hsbill
oracle Jul ? : ora_ckpt_hsbill
oracle Jul ? : ora_smon_hsbill
oracle Jul ? : ora_reco_hsbill
oracle Jul ? : ora_cjq_hsbill
oracle Nov ? : ora_j_hsbill
oracle Nov ? : ora_j_hsbill
oracle Nov ? : ora_j_hsbill
oracle Nov ? : ora_j_hsbill
oracle :: ? : ora_j_hsbill
$ pmap
: ora_ckpt_hsbill
K read/exec /opt/oracle/product//bin/oracle
E K read/write/exec /opt/oracle/product//bin/oracle
K read/write/exec [ heap ]
K read/write/exec/shared [ ism shmid=x ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCC K read/write/exec [ anon ]
FFFFFFFFCE K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCB K read/write/exec [ anon ]
FFFFFFFFCC K read/write/exec [ anon ]
FFFFFFFFCD K read/write/exec [ anon ]
FFFFFFFFCDA K read/write/exec [ anon ]
FFFFFFFFCE K read/write/exec [ anon ]
FFFFFFFFCEC K read/write/exec [ anon ]
FFFFFFFFCFA K read/write/exec [ anon ]
FFFFFFFFCFE K read/write/exec [ anon ]
FFFFFFFFCC K read/write/exec [ anon ]
FFFFFFFFC K read/write/exec [ anon ]
FFFFFFFFCE K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCAA K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCAC K read/write/exec [ anon ]
FFFFFFFFCAA K read/write/exec [ anon ]
FFFFFFFFCAE K read/write/exec [ anon ]
FFFFFFFFCAC K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCAE K read/write/exec [ anon ]
FFFFFFFFCA K read/write/exec [ anon ]
FFFFFFFFCAA K read/write/exec [ anon ]
FFFFFFFFCAA K read/write/exec [ anon ]
FFFFFFFFCAB K read/write/exec [ anon ]
FFFFFFFFCAB K read/write/exec [ anon ]
FFFFFFFFCAC K read/write/exec [ anon ]
FFFFFFFFCAC K read/write/exec [ anon ]
FFFFFFFFCAD K read/write/exec [ anon ]
FFFFFFFFCADA K read/write/exec [ anon ]
FFFFFFFFCAE K read/write/exec [ anon ]
FFFFFFFFCAEC K read/write/exec [ anon ]
FFFFFFFFCAFA K read/write/exec [ anon ]
FFFFFFFFCAFE K read/write/exec [ anon ]
FFFFFFFFCBC K read/write/exec [ anon ]
FFFFFFFFCB K read/write/exec [ anon ]
FFFFFFFFCBE K read/write/exec [ anon ]
FFFFFFFFCC K read/write/exec [ anon ]
FFFFFFFFCD K read/exec /usr/lib/sparcv/nss_filesso
FFFFFFFFCE K read/write/exec /usr/lib/sparcv/nss_filesso
FFFFFFFFCF K read/write [ anon ]
FFFFFFFFCF K read/write [ anon ]
FFFFFFFFCF K read/write [ anon ]
FFFFFFFFCF K read/write [ anon ]
FFFFFFFFCF K read/write [ anon ]
FFFFFFFFD K read/exec /usr/platform/sunu/lib/sparcv/libc_psrso
FFFFFFFFD K read/exec /usr/lib/sparcv/libmpso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libmpso
FFFFFFFFD K read/write/exec [ anon ]
FFFFFFFFD K read/exec /usr/lib/sparcv/libmso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libmso
FFFFFFFFD K read/exec /usr/lib/sparcv/libkstatso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libkstatso
FFFFFFFFD K read/exec /usr/lib/sparcv/librtso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/librtso
FFFFFFFFDA K read/exec /usr/lib/sparcv/libaioso
FFFFFFFFDB K read/write/exec /usr/lib/sparcv/libaioso
FFFFFFFFDC K read/exec /usr/lib/sparcv/libcso
FFFFFFFFDDB K read/write/exec /usr/lib/sparcv/libcso
FFFFFFFFDDC K read/write/exec /usr/lib/sparcv/libcso
FFFFFFFFDF K read/write/exec [ anon ]
FFFFFFFFE K read/exec /usr/lib/sparcv/libgenso
FFFFFFFFE K read/write/exec /usr/lib/sparcv/libgenso
FFFFFFFFE K read/exec /usr/lib/sparcv/libnslso
FFFFFFFFEA K read/write/exec /usr/lib/sparcv/libnslso
FFFFFFFFEB K read/write/exec /usr/lib/sparcv/libnslso
FFFFFFFFE K read/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEA K read/write/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEA K read/write/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEB K read/exec /usr/lib/sparcv/libsocketso
FFFFFFFFECE K read/write/exec /usr/lib/sparcv/libsocketso
FFFFFFFFED K read/write/exec [ anon ]
FFFFFFFFEE K read/exec /opt/oracle/product//lib/libskgxnso
FFFFFFFFEF K read/write/exec /opt/oracle/product//lib/libskgxnso
FFFFFFFFF K read/exec /opt/oracle/product//lib/libskgxpso
FFFFFFFFF K read/write/exec /opt/oracle/product//lib/libskgxpso
FFFFFFFFF K read/exec /opt/oracle/product//lib/libodmdso
FFFFFFFFF K read/write/exec /opt/oracle/product//lib/libodmdso
FFFFFFFFF K read/exec /usr/lib/sparcv/libdlso
FFFFFFFFF K read/write/exec [ anon ]
FFFFFFFFF K read/exec /usr/lib/sparcv/ldso
FFFFFFFFF K read/write/exec /usr/lib/sparcv/ldso
FFFFFFFFFFFA K read/write [ stack ]
total K
$
计算后台进程使用的内存资源:
K K = k
这就是一个进程所消耗的内存
用户进程内存使用举例
$ ps ef|grep LOCAL
oracle :: pts/ : grep LOCAL
oracle Nov ? : oraclehsbill (LOCAL=NO)
oracle Nov ? : oraclehsbill (LOCAL=NO)
$ pmap
: oraclehsbill (LOCAL=NO)
K read/exec /opt/oracle/product//bin/oracle
E K read/write/exec /opt/oracle/product//bin/oracle
K read/write/exec [ heap ]
K read/write/exec/shared [ ism shmid=x ]
FFFFFFFFCC K read/write [ anon ]
FFFFFFFFCC K read/write [ anon ]
FFFFFFFFCC K read/write [ anon ]
FFFFFFFFCC K read/write [ anon ]
FFFFFFFFCD K read/write/exec [ anon ]
FFFFFFFFCE K read/exec /usr/lib/sparcv/nss_filesso
FFFFFFFFCF K read/write/exec /usr/lib/sparcv/nss_filesso
FFFFFFFFD K read/exec /usr/platform/sunu/lib/sparcv/libc_psrso
FFFFFFFFD K read/exec /usr/lib/sparcv/libmpso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libmpso
FFFFFFFFD K read/write/exec [ anon ]
FFFFFFFFD K read/exec /usr/lib/sparcv/libmso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libmso
FFFFFFFFD K read/exec /usr/lib/sparcv/libkstatso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/libkstatso
FFFFFFFFD K read/exec /usr/lib/sparcv/librtso
FFFFFFFFD K read/write/exec /usr/lib/sparcv/librtso
FFFFFFFFDA K read/exec /usr/lib/sparcv/libaioso
FFFFFFFFDB K read/write/exec /usr/lib/sparcv/libaioso
FFFFFFFFDC K read/exec /usr/lib/sparcv/libcso
FFFFFFFFDDB K read/write/exec /usr/lib/sparcv/libcso
FFFFFFFFDDC K read/write/exec /usr/lib/sparcv/libcso
FFFFFFFFDF K read/write/exec [ anon ]
FFFFFFFFE K read/exec /usr/lib/sparcv/libgenso
FFFFFFFFE K read/write/exec /usr/lib/sparcv/libgenso
FFFFFFFFE K read/exec /usr/lib/sparcv/libnslso
FFFFFFFFEA K read/write/exec /usr/lib/sparcv/libnslso
FFFFFFFFEB K read/write/exec /usr/lib/sparcv/libnslso
FFFFFFFFE K read/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEA K read/write/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEA K read/write/exec /opt/oracle/product//lib/libjoxso
FFFFFFFFEB K read/exec /usr/lib/sparcv/libsocketso
FFFFFFFFECE K read/write/exec /usr/lib/sparcv/libsocketso
FFFFFFFFED K read/write/exec [ anon ]
FFFFFFFFEE K read/exec /opt/oracle/product//lib/libskgxnso
FFFFFFFFEF K read/write/exec /opt/oracle/product//lib/libskgxnso
FFFFFFFFF K read/exec /opt/oracle/product//lib/libskgxpso
FFFFFFFFF K read/write/exec /opt/oracle/product//lib/libskgxpso
FFFFFFFFF K read/exec /opt/oracle/product//lib/libodmdso
FFFFFFFFF K read/write/exec /opt/oracle/product//lib/libodmdso
FFFFFFFFF K read/exec /usr/lib/sparcv/libdlso
FFFFFFFFF K read/write/exec [ anon ]
FFFFFFFFF K read/exec /usr/lib/sparcv/ldso
FFFFFFFFF K read/write/exec /usr/lib/sparcv/ldso
FFFFFFFFFFF K read/write [ stack ]
total K
$
从PMAP的输出中我们可以看到进程所调用的库文件等及其读写状态