观察oracle进程占用内存

Background进程占用的内存:
oracle@adam-desktop:/home/adam$ ps aux | head -1; ps aux | grep ora_ | grep -v grep
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
oracle    4315  0.0  0.7 508120 12684 ?        Ss   09:42   0:03 ora_pmon_orcl
oracle    4317  0.0  0.6 507484 10880 ?        Ss   09:42   0:00 ora_psp0_orcl
oracle    4319  0.0  1.2 507484 21908 ?        Ss   09:42   0:00 ora_mman_orcl
oracle    4321  0.0  4.5 509040 81652 ?        Ss   09:42   0:02 ora_dbw0_orcl
oracle    4323  0.0  1.1 523036 20244 ?        Ss   09:42   0:01 ora_lgwr_orcl
oracle    4325  0.0  1.0 509156 19508 ?        Ss   09:42   0:11 ora_ckpt_orcl
oracle    4327  0.0  3.9 509044 71180 ?        Ss   09:42   0:01 ora_smon_orcl
oracle    4329  0.0  0.9 507484 17172 ?        Ss   09:42   0:00 ora_reco_orcl
oracle    4331  0.0  1.4 509092 26384 ?        Ss   09:42   0:02 ora_cjq0_orcl
oracle    4333  0.0  3.2 510264 58108 ?        Ss   09:42   0:02 ora_mmon_orcl
oracle    4335  0.0  0.7 507484 14040 ?        Ss   09:42   0:02 ora_mmnl_orcl
oracle    4337  0.0  0.5 508124 10812 ?        Ss   09:42   0:00 ora_d000_orcl
oracle    4339  0.0  0.5 508116 10512 ?        Ss   09:42   0:00 ora_s000_orcl
oracle    4342  0.0  0.8 507484 15336 ?        Ss   09:42   0:00 ora_rvwr_orcl
oracle    4349  0.0  1.2 523036 22128 ?        Ss   09:42   0:00 ora_arc0_orcl
oracle    4351  0.0  1.2 523036 22092 ?        Ss   09:42   0:00 ora_arc1_orcl
oracle    4355  0.0  0.6 507484 12116 ?        Ss   09:42   0:00 ora_qmnc_orcl
oracle    4376  0.0  1.0 507996 19212 ?        Ss   09:42   0:00 ora_q000_orcl
oracle    4382  0.0  0.6 507480 11392 ?        Ss   09:43   0:00 ora_q002_orcl
oracle    6698  0.1  1.1 508004 20956 ?        Ss   14:52   0:00 ora_j000_orcl


oracle@adam-desktop:/home/adam$ ps aux | grep ora_ | grep -v grep |awk 'BEGIN {total=0} {total+=$6} END {print total}'
499572

总计约50M

VSZ和RSS列的含义:
VSZ virtual memory size of the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change. (alias vsize).
RSS resident set size, the non-swapped physical memory that a task has used (in kiloBytes). (alias rssize, rsz).

空闲User进程占用的内存:

oracle@adam-desktop:/home/adam$ ps aux | head -1; ps aux | grep LOCAL | grep -v grep
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
oracle    6702  0.0  1.2 507612 23104 ?        Ss   14:52   0:00 oracleorcl (LOCAL=NO)
oracle    6998  0.0  1.3 509152 24760 ?        Ss   15:04   0:00 oracleorcl (LOCAL=NO)
oracle    7046  0.0  0.9 507612 16316 ?        Ss   15:05   0:00 oracleorcl (LOCAL=NO)

oracle占用的共享内存段
oracle@adam-desktop:/home/adam$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0xe53c4b00 557071 oracle 640 423624704 23
SYSTEM@orcl>show parameter sga_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_target big integer 400M

可以看出两者的大小基本是一致的。

使用pmap查看进程7046的详细内存空间

oracle@adam-desktop:/home/adam$ pmap 7046
7046: oracleorcl (LOCAL=NO)
08048000 77428K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/bin/oracle
0cbe5000 12K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/bin/oracle
0cbe8000 316K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/bin/oracle
0cc37000 120K rwx-- [ anon ]
0dbda000 396K rwx-- [ anon ]
20000000 413696K rwxs- [ shmid=0x8800f ]
b68cd000 40K r-x-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
b68d7000 4K r-x-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
b68d8000 4K rwx-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
b68d9000 36K r-x-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
b68e2000 4K r-x-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
b68e3000 4K rwx-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
b68e4000 24K r-x-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
b68ea000 4K r-x-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
b68eb000 4K rwx-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
b68ec000 80K rwx-- /dev/zero
b6900000 64K rwx-- /dev/zero
b6910000 64K rwx-- /dev/zero
b6920000 64K rwx-- /dev/zero
b6930000 64K rwx-- /dev/zero
b6940000 64K rwx-- /dev/zero
b6950000 112K rwx-- /dev/zero
b696c000 1496K rwx-- [ anon ]
b6ae2000 1272K r-x-- /lib/tls/i686/cmov/libc-2.10.1.so
b6c20000 8K r-x-- /lib/tls/i686/cmov/libc-2.10.1.so
b6c22000 4K rwx-- /lib/tls/i686/cmov/libc-2.10.1.so
b6c23000 12K rwx-- [ anon ]
b6c26000 76K r-x-- /lib/tls/i686/cmov/libnsl-2.10.1.so
b6c39000 4K r-x-- /lib/tls/i686/cmov/libnsl-2.10.1.so
b6c3a000 4K rwx-- /lib/tls/i686/cmov/libnsl-2.10.1.so
b6c3b000 8K rwx-- [ anon ]
b6c3d000 84K r-x-- /lib/tls/i686/cmov/libpthread-2.10.1.so
b6c52000 4K r-x-- /lib/tls/i686/cmov/libpthread-2.10.1.so
b6c53000 4K rwx-- /lib/tls/i686/cmov/libpthread-2.10.1.so
b6c54000 8K rwx-- [ anon ]
b6c56000 144K r-x-- /lib/tls/i686/cmov/libm-2.10.1.so
b6c7a000 4K r-x-- /lib/tls/i686/cmov/libm-2.10.1.so
b6c7b000 4K rwx-- /lib/tls/i686/cmov/libm-2.10.1.so
b6c7c000 4K rwx-- [ anon ]
b6c7d000 8K r-x-- /lib/tls/i686/cmov/libdl-2.10.1.so
b6c7f000 4K r-x-- /lib/tls/i686/cmov/libdl-2.10.1.so
b6c80000 4K rwx-- /lib/tls/i686/cmov/libdl-2.10.1.so
b6c81000 4K r-x-- /lib/libaio.so.1.0.1
b6c82000 4K r-x-- /lib/libaio.so.1.0.1
b6c83000 4K rwx-- /lib/libaio.so.1.0.1
b6c94000 1904K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libnnz10.so
b6e70000 152K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libnnz10.so
b6e96000 8K rwx-- [ anon ]
b6e98000 88K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libdbcfg10.so
b6eae000 8K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libdbcfg10.so
b6eb0000 32K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libclsra10.so
b6eb8000 4K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libclsra10.so
b6eb9000 4K rwx-- [ anon ]
b6eba000 7028K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libjox10.so
b7597000 260K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libjox10.so
b75d8000 4K rwx-- [ anon ]
b75d9000 344K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocrutl10.so
b762f000 16K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocrutl10.so
b7633000 4K rwx-- [ anon ]
b7634000 268K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocrb10.so
b7677000 4K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocrb10.so
b7678000 436K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocr10.so
b76e5000 4K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libocr10.so
b76e6000 4K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libskgxn2.so
b76e7000 4K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libskgxn2.so
b76e8000 4K rwx-- [ anon ]
b76e9000 880K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libhasgen10.so
b77c5000 20K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libhasgen10.so
b77ca000 12K rwx-- [ anon ]
b77cd000 128K r-x-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libskgxp10.so
b77ed000 8K rwx-- /opt/ora10g/oracle/product/10.2.0/db_1/lib/libskgxp10.so
b77ef000 8K rwx-- [ anon ]
b77f1000 4K r-x-- [ anon ]
b77f2000 108K r-x-- /lib/ld-2.10.1.so
b780d000 4K r-x-- /lib/ld-2.10.1.so
b780e000 4K rwx-- /lib/ld-2.10.1.so
bff00000 84K rwx-- [ stack ]
total 507612K

上面红色部分为使用的SGA内存空间,shmid 0x8800f转换为十进制为557071,和ipcs -m中看到的shmid一致。

SYSTEM@orcl>select to_number('8800f','xxxxx') from dual;
TO_NUMBER('8800F','XXXXX')
--------------------------
557071

参考资料:
Oracle进程内存结构-如何察看Oracle进程消耗的内存
如何给Oracle数据库分配内存?

Comments are closed.