共享内存 share pool (1):heap /extent /chunk/

相关概念

  • CHUNK: Shared pool物理层面上由许多内存块组成,这些内在块称为chunk。但是chunk是大小不一的,在内存中一个chunk是连续的。
  • EXTENT:由多个连续的chunk组成
  • HEAP: 堆由一个或多个大小不一的extent组成

将shool pool内存dump出来

将shool pool内存dump出来:

[oracle@oracle ~]$ sqlplus /nolog
SQL> conn /as sysdba
SQL> alter session set events 'immediate trace name heapdump level 2';
SQL> select value from v$diag_info where name like 'De%';
VALUE
--------------------------------------------------------------------------------
/u01/diag/rdbms/oracle/beijing/trace/beijing_ora_14649.trc

SQL> 

解释文件中各个部分

******************************************************
Trace file /u01/diag/rdbms/oracle/beijing/trace/beijing_ora_9252.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
System name:    Linux
Node name:    oracle.11g
Release:    2.6.9-55.EL
Version:    #1 Wed May 2 13:52:16 EDT 2007
Machine:    i686
Instance name: beijing
Redo thread mounted by this instance: 1
Oracle process number: 36
Unix process pid: 9252, image: oracle@oracle.11g (TNS V1-V3)


*** 2015-03-11 09:29:17.546
*** SESSION ID:(46.362) 2015-03-11 09:29:17.546
*** CLIENT ID:() 2015-03-11 09:29:17.546
*** SERVICE NAME:(SYS$USERS) 2015-03-11 09:29:17.546
*** MODULE NAME:(sqlplus@oracle.11g (TNS V1-V3)) 2015-03-11 09:29:17.546
*** ACTION NAME:() 2015-03-11 09:29:17.546

    这部分是关于trace文件的基本信息,oracle版本、资源情况、用户和会话等
******************************************************

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: 0x387af42c  Index: 1  Flags:  3  State: 2  next:  (nil)
Slot [  3] Latch: 0x387af4b4  Index: 1  Flags:  3  State: 2  next:  0x200a7f60
Slot [  4] Latch: 0x200087dc  Index: 1  Flags:  3  State: 2  next:  (nil)
........

 这部分记录的是shared pool中的latch信息。每个latch的具体信息可以通过视图V$LATCH、V$LATCH_PARENT、V$LATCH_CHILDREN或者表x$ksllt查出
******************************************************

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: 0x2002a6f0 0x2002b328 0x2002bf60 0x2002cb98
 reserved granule count 0 (granule size 4194304)
 
 这是堆dump信息的头部,heap name说明了内存所述的堆,shared pool是属于SGA区的,因此,这里是"sga heap"
******************************************************

HEAP DUMP heap name="sga heap(1,0)"  desc=0x2002a6f0
 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)
 
 先了解两个概念:子缓冲池,子分区。
 从Oracle 9i开始,Shared Pool可以被分割为多个子缓冲池(SubPool)进行管理,以提高并发性,减少竞争。Shared Pool的每个SubPool可以被看作是一个Mini Shared Pool,拥有自己独立的Free List、内存结构以及LRU List。
 
 当仅有一个子缓冲池时,Shared Pool被划分为sga heap(1,0)~sga heap(1,3),共4个子分区
 HEAP DUMP heap name="sga heap(1,0)"  desc=0x2002a6f0
 HEAP DUMP heap name="sga heap(1,1)"  desc=0x2002b328
 HEAP DUMP heap name="sga heap(1,2)"  desc=0x2002bf60
 HEAP DUMP heap name="sga heap(1,3)"  desc=0x2002cb98

 当使用两个子缓冲池时,Shared Pool则被划分为8个子分区进行管理:
 HEAP DUMP heap name="sga heap(1,0)"   
 HEAP DUMP heap name="sga heap(1,1)" 
 HEAP DUMP heap name="sga heap(1,2)"
 HEAP DUMP heap name="sga heap(1,3)"
 HEAP DUMP heap name="sga heap(2,0)"
 HEAP DUMP heap name="sga heap(2,1)" 
 HEAP DUMP heap name="sga heap(2,2)"
 HEAP DUMP heap name="sga heap(2,3)"
 
******************************************************
EXTENT 0 addr=0x33800000
  Chunk 33800038 sz=       24  R-freeable  "reserved stoppe"
  Chunk 33800050 sz=   212888  R-free      "               "
  Chunk 33833fe8 sz=       24  R-freeable  "reserved stoppe"
  Chunk 33834000 sz=  3981312    perm      "perm           "  alo=1227684
.......
.......
EXTENT 16 addr=0x39000000 --起始地址
  Chunk 39000038 sz=       24  R-freeable  "reserved stoppe" --39000038为十六进制地址,sz为Chunk大小
  Chunk 39000050 sz=   212888  R-free      "               "
  Chunk 39033fe8 sz=       24  R-freeable  "reserved stoppe"
  Chunk 39034000 sz=  3980148    perm      "perm           "  alo=3980148
  Chunk 393ffb74 sz=     1016    perm      "perm           "  alo=1016
  Chunk 393fff6c sz=      148    free      "               "
Total heap size    = 71302216                                --这一shared pool区的总的大小
    
    每个分区中的EXTENT都是由连续,但大小不等的Chunk组成。

    Chunk可以分为4类-或者叫4种状态:
    1.free:chunk中没有有效的对象,可以不受限制的分配
    2.recr:recreatable,--可重用的,chunk里面包含的对象可以被临时性的移    走,如果需要,可以重建,例如共享SQL语句
    3.freeabl:--可释放的,session用过这个chunk,里面存放的对象数据是session    在处理过程中产生的,没有办法重建,这点不同于recr。因此这个chunk不能被临时性的移走。但是在合适的时间段可以被释放。
    4.permpermanent--永久的SGA的固定对象等,chunk中包含永久性的对象,但是大型的permanent类型的chunk中可能包含可用空间,需要的时候,这些空间可以被释放。
  
******************************************************

 参考blog:

http://blog.csdn.net/haibusuanyun/article/details/17803523

http://www.hellodba.com/reader.php?ID=111&lang=CN

http://book.51cto.com/art/201001/177241.htm

原文地址:https://www.cnblogs.com/polestar/p/4353785.html