Oracle Share Pool内部管理机制(一)

2014-11-24 17:17:56 · 作者: · 浏览: 1

SHARE POOL利用堆(HEAP)的内存管理方式管理,在物理上由多个内存区(EXTENT)组成,内存区又由多个不同大小的CHUNK组成。而CHUNK又有可重用和空闲之分,并且它们分别有LRU LIST、FREE LIST、RESERVED LIST串联起来。


Oracle Share Pool内部管理机制


堆管理


Chunk的使用情况可由X$KSMSP内部视图查看。每个堆头上则包含了可使用的chunk列表和已使用的chunk列表。通过dump heap命令可以在trace文件中观察heap和extent的关系。


alter system set events 'immediate trace name heapdump level 2';


--------------------------------------------------------------------------------


--------------------------------------------------------------------------------


案例:


SQL> select name,bytes/1024/1024 from v$sgainfo;


NAME BYTES/1024/1024


-------------------------------- ---------------


Fixed SGA Size 1.27566528


Redo Buffers 5.59765625


Buffer Cache Size 180


Shared Pool Size 104


Large Pool Size 4


Java Pool Size 4


Streams Pool Size 0


Shared IO Pool Size 0


Granule Size 4


Maximum SGA Size 498.875


Startup overhead in Shared Pool 52


NAME BYTES/1024/1024


-------------------------------- ---------------


Free SGA Memory Available 200


12 rows selected.


[oracle@node1 ~]$ more /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_14983.trc


Trace file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_14983.trc


Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production


With the Partitioning, OLAP, Data Mining and Real Application Testing options


ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1


System name: Linux


Node name: node1


Release: 2.6.18-194.el5


Version: #1 SMP Tue Mar 16 21:52:43 EDT 2010


Machine: i686


Instance name: prod


Redo thread mounted by this instance: 1


Oracle process number: 32


Unix process pid: 14983, image: oracle@node1 (TNS V1-V3)


*** 2014-07-02 14:58:47.532


*** SESSION ID:(32.758) 2014-07-02 14:58:47.532


*** CLIENT ID:() 2014-07-02 14:58:47.532


*** SERVICE NAME:(SYS$USERS) 2014-07-02 14:58:47.532


*** MODULE NAME:(sqlplus@node1 (TNS V1-V3)) 2014-07-02 14:58:47.532


*** ACTION NAME:() 2014-07-02 14:58:47.532


KGH Latch Directory Information


ldir state: 2 last allocated slot: 99


Slot [ 1] Latch: 0x200065ec Index: 1 Flags: 3 State: 2 next: (nil)


Slot [ 2] Latch: 0x3e75571c Index: 1 Flags: 3 State: 2 next: (nil)



......(省略)



Slot [ 99] Latch: 0x2002616c Index: 1 Flags: 3 State: 2 next: 0x1


******************************************************


HEAP DUMP heap name="sga heap" desc=0x200010b4


extent sz=0x7ad4 alt=124 het=32767 rec=9 flg=-126 opc=0


parent=(nil) owner=(nil) nex=(nil) xsz=0x0 heap=(nil)


fl2=0x60, nex=(nil)


ds for latch 1: 0x2002a990 0x2002b5c8 0x2002c200 0x2002ce38


reserved granule count 0 (granule size 4194304)


******************************************************


HEAP DUMP heap name="sga heap(1,0)" desc=0x2002a990


extent sz=0xfc4 alt=124 het=32767 rec=9 flg=-126 opc=0


parent=(nil) owner=(nil) nex=(nil) xsz=0x400000 heap=(nil)


fl2=0x20, nex=(nil)


latch set 1 of 1


durations enabled for this heap


reserved granules for root 0 (granule size 4194304)


EXTENT 0 addr=0x3b800000


Chunk 3b800038 sz= 24 R-freeable "reserved stoppe"


Chunk 3b800050 sz= 212888 R-free " "


Chunk 3b833fe8 sz= 24 R-freeable "reserved stoppe"


Chunk 3b834000 sz= 3981312 perm "perm " alo=3290272


EXTENT 1 addr=0x3bc00000


Chunk 3bc000