基于参数shared_pool_reserved_size进一步理解共享池shared pool原理

Posted yaoyangding

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于参数shared_pool_reserved_size进一步理解共享池shared pool原理相关的知识,希望对你有一定的参考价值。

基于参数shared_pool_reserved_size进一步理解共享池shared pool原理

原创 Oracle 作者:wisdomone1 时间:2015-11-23 21:02:50 10596 0

结论

1,与共享池相关的参数为:shared_pool_size,shared_pool_reserved_size,_shared_pool_reserved_pct
  _shared_pool_reserved_min_alloc
2,shared_pool_reserved_size一般默认是shared_pool_size的5%,这个比例由参数_shared_pool_reserved_pct控制
3,_shared_pool_reserved_min_alloc控制保留池中最小的分配大小,默认大小为4400,其取值范围为4000bytes到60M之间(当然这是基于当前共享池大小)
  否则会报错数据库无法重启
4,调整  shared_pool_reserved_size,_shared_pool_reserved_pct,_shared_pool_reserved_min_alloc全要重启库方可
5,调整上述的参数可以是相互独立,即调整一个参数后,其它参数不会动态进行相应的调整,仍保持原值
6,每个保留列表对应堆HEAP,即多少个堆就有多少个保留列表
  每个保留列表下面包括14个BUCKET
7,调整上述几个参数,发现保留列表相关数据没有发生明显的变化,当然,也限于我对这块的理解还不到位
8,x$ksmspr记录保留区CHUNK的分配情况,CHUNK大小共计2种,第1种为48字节,第2种为4529992即4424K,具体测试见  经过在UE进行查找分析比对 (在文章进行匹配查找即可)
 
9,关于x$ksmspr的使用,请见下面测试之 --获知与CHUNK分配相关的X视图(在文章进行匹配查找即可)

10,x$ksmsp是x$ksmspr的父集,即前者包含后者

测试



----oracle version
SQL> select * from v$version where rownum=1;


BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi


--与保留区相关的参数,可见shared_pool_reserved_size=shared_pool_size*_shared_pool_reserved_pct,且_shared_pool_reserved_pct默认值为5%
SQL> show parameter shared_pool


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_pool_reserved_size            big integer 44M
shared_pool_size                     big integer 0


控制从共享池分配多大比例给保留池,可见为5%
_shared_pool_reserved_pct                          5                                                  percentage memory of the shared pool allocated for
                                                                                                       the reserved area
保留池中最小的分配大小为4400字节,也就是小于这个大小,不会从保留池分配内存,只会从FREE LIST及LRU LIST分配内存
_shared_pool_reserved_min_alloc                    4400                                               minimum allocation size in bytes for reserved area
                                                                                                       of shared pool


v$sgainfo或者__shared_pool_size可得到当前共享池的大小
SQL> select name,bytes/1024/1024 as mb,resizeable from v$sgainfo where name=‘Shared Pool Size‘;


NAME                                     MB RES
-------------------------------- ---------- ---
Shared Pool Size                        832 Yes


__shared_pool_size                                 872415232                                          Actual size in bytes of shared pool


      


SQL> select 872415232*0.05/1024/1024 mb from dual;


        MB
----------
      41.6                                                                                                                                                                                                            


先研究下参数shared_pool_reserved_size调整对于共享池内存分配的影响
----未调整shared_pool_reserved_size前
----共计4个heap
SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_14042.trc|grep -i --color sga
HEAP DUMP heap name="sga heap"  desc=0x60000058
HEAP DUMP heap name="sga heap(1,0)"  desc=0x60034fe0
HEAP DUMP heap name="sga heap(1,1)"  desc=0x60036838
  Chunk        0a3b7bc20 sz=  4190296    recreate  "KSFD SGA I/O b "  latch=(nil)
HEAP DUMP heap name="sga heap(1,2)"  desc=0x60038090
HEAP DUMP heap name="sga heap(1,3)"  desc=0x600398e8


---可见每个heap对应一个保留区的free list,共计4个
SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_14042.trc|grep -i --color "RESERVED FREE LISTS:"
RESERVED FREE LISTS:
RESERVED FREE LISTS:
RESERVED FREE LISTS:
RESERVED FREE LISTS:


--可见每个保留区的free list包含14个bucket,共计56个bucket,并且在RESERVED EXTENTS部分会包含每个保留区free list中bucket中的chunk(大家可以这样理解,ORACLE是采用BUCKET来管理分配不同大小的内存)
SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_14042.trc|grep -i --color RESERVED
 reserved granule count 46 (granule size 16777216)
RESERVED EXTENTS
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a1000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a10ccfd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a2000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a20ccfd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a4000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a40ccfd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  2518488
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a3000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a30ccfd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =   839496
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a0000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a00ccfd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =   839496
 reserved granules for root 46 (granule size 16777216)
  Chunk        09f000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09f0ccfd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =   839496


SQL> 


---调整shared_pool_reserved_size,由值44M增加到60M
SQL> alter system set shared_pool_reserved_size=60m;
alter system set shared_pool_reserved_size=60m
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified




SQL> alter system set shared_pool_reserved_size=60m scope=spfile;


System altered.


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.


Total System Global Area 1157627904 bytes
Fixed Size                  2095800 bytes
Variable Size            1040188744 bytes
Database Buffers           83886080 bytes
Redo Buffers               31457280 bytes
Database mounted.
Database opened.
SQL> show parameter shared_pool


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_pool_reserved_size            big integer 60M
shared_pool_size                     big integer 0


可见调整shared_pool_reserved_size,参数_shared_pool_reserved_pct不会进行调整
_shared_pool_reserved_pct                          5                                                  percentage memory of the shared pool allocated for
                                                                                                       the reserved area
可见共享池大小,不然因为保留区大小调整而变化
__shared_pool_size                                 872415232                                          Actual size in bytes of shared pool     








---仅列举重点关注的内容,可见和调整shared_pool_reserved_size前没有变化
SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_14757.trc|grep -i --color RESERVED
 reserved granule count 46 (granule size 16777216)
RESERVED EXTENTS
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a1000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a111efd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a2000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a211efd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a4000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a411efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  3526104
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a3000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a311efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a0000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a011efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368
 reserved granules for root 46 (granule size 16777216)
  Chunk        09f000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09f11efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368




---换个思路继续测试,调整_shared_pool_reserved_pct参数,看看保留区变化,可见共享池大小没有变化,且好像shared_pool_reserved_size没有变化,因为shared_pool_reserved_size=shared_pool_size*_shared_pool_reserved_pct
SQL> alter system set "_shared_pool_reserved_pct"=15;
alter system set "_shared_pool_reserved_pct"=15
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified




SQL> alter system set "_shared_pool_reserved_pct"=15 scope=spfile;


System altered.


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.


Total System Global Area 1157627904 bytes
Fixed Size                  2095800 bytes
Variable Size            1040188744 bytes
Database Buffers           83886080 bytes
Redo Buffers               31457280 bytes
Database mounted.
Database opened.
SQL> 


SQL> show parameter reserved


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
_shared_pool_reserved_pct            integer     15
shared_pool_reserved_size            big integer 60M




SQL> select 872415232*0.15/1024/1024 mb from dual;


        MB
----------
     124.8


好像调整_shared_pool_reserved_pct参数后,保留区仍没有变化或调整
SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_15156.trc|grep -i "reserved"
 reserved granule count 46 (granule size 16777216)
RESERVED EXTENTS
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a1000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a111efd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a2000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a211efd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a4000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a411efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  3526104
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a3000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a311efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368
 reserved granules for root 46 (granule size 16777216)
  Chunk        0a0000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a011efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368
 reserved granules for root 46 (granule size 16777216)
  Chunk        09f000058 sz=       48  R-freeable  "reserved stoppe"  --对应X$KSMSPR,且R-freeable对应X$KSMSPR的列值R-freea
  Chunk        09f11efd0 sz=       48  R-freeable  "reserved stoppe"
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
Total reserved free space   =  1175368  


--获知与CHUNK分配相关的X视图
SQL> select * from x$kqfta where lower(kqftanam) like  ‘%x$ksmsp%‘;


ADDR                   INDX    INST_ID   KQFTAOBJ   KQFTAVER KQFTANAM                         KQFTATYP   KQFTAFLG   KQFTARSZ   KQFTACOC
---------------- ---------- ---------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
0000000005A592E8         65          1 4294951100          4 X$KSMSP                                 4          0         88         11
0000000005A59330         66          1 4294951170          3 X$KSMSPR                                4          0         88          9
0000000005A594E0         72          1 4294951768          1 X$KSMSP_DSNEW                           1          0       6472          8
0000000005A59528         73          1 4294951769          1 X$KSMSP_NWEX                            4          0         64         13


可知
X$KSMSPR记录与保留区相关的chunk分配信息,下基于此X表进行分析保留区


可见ksmchptr即上述DUMP中的CHUNK的地址
SQL> select * from  x$ksmspr where KSMCHSIZ=48 and ksmchptr=‘00000000A1000058‘ or ksmchptr=‘00000000A111EFD0‘;


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002AAB5A233E00         15          1 reserved stoppe  00000000A111EFD0         48 R-freea           0 00
00002AAB5A233D50         17          1 reserved stoppe  00000000A1000058         48 R-freea           0 00


不过DUMP出来的保留区仅6个CHUNK,但如下显示12个CHUNK,余下的6个CHUNK为何没显示在DUMP中呢,此问题先放在这儿
SQL> select * from  x$ksmspr where KSMCHSIZ=48;


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002AAB5A234328          0          1 reserved stoppe  000000009F11EFD0         48 R-freea           0 00
00002AAB5A234278          2          1 reserved stoppe  000000009F000058         48 R-freea           0 00
00002AAB5A234220          3          1 reserved stoppe  00000000A011EFD0         48 R-freea           0 00
00002AAB5A234170          5          1 reserved stoppe  00000000A0000058         48 R-freea           0 00
00002AAB5A234118          6          1 reserved stoppe  00000000A311EFD0         48 R-freea           0 00
00002AAB5A234068          8          1 reserved stoppe  00000000A3000058         48 R-freea           0 00
00002AAB5A234010          9          1 reserved stoppe  00000000A411EFD0         48 R-freea           0 00
00002AAB5A233F60         11          1 reserved stoppe  00000000A4000058         48 R-freea           0 00
00002AAB5A233F08         12          1 reserved stoppe  00000000A211EFD0         48 R-freea           0 00
00002AAB5A233E58         14          1 reserved stoppe  00000000A2000058         48 R-freea           0 00
00002AAB5A233E00         15          1 reserved stoppe  00000000A111EFD0         48 R-freea           0 00


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002AAB5A233D50         17          1 reserved stoppe  00000000A1000058         48 R-freea           0 00


12 rows selected.


--从另一个维度研究,大家知道保留区也是共享池一部分,正常情况下分配内存只会从FREE LIST及LRU LIST分配,如果我调小参数_shared_pool_reserved_min_alloc,分配内存更会从保留区分配内存,是不是这样呢
,还是为了研究保留区的内存分配一些机制
--注意:仅是为了研究原理与算法,请在生产中不要这样调整
__shared_pool_size                                 872415232                                          Actual size in bytes of shared pool


shared_pool_reserved_size                          62914560                                           size in bytes of reserved area of shared pool


---可见默认情况下,从保留区分配内存最小的内存大小为4400字节
_shared_pool_reserved_min_alloc                    4400                                               minimum allocation size in bytes for reserved area
                                                                                                       of shared pool
可见调整参数_shared_pool_reserved_min_alloc必须要重启库,且参数必须在4000字节与60m之间,否则数据库无法重启,说明数据库底层对于一些参数调整有非常复杂的算法控制的,不是简单调整一个参数就可以了
SQL> alter system set "_shared_pool_reserved_min_alloc"=10;
alter system set "_shared_pool_reserved_min_alloc"=10
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified




SQL> alter system set "_shared_pool_reserved_min_alloc"=100 scope=spfile;


System altered.


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00093: _shared_pool_reserved_min_alloc must be between 4000 and 62914560
SQL> 
基于SPFILE调整PFILE,恢复参数_shared_pool_reserved_min_alloc,然后再次重启库
[ora10g@seconary dbs]$ strings spfileora10g.ora|grep reser
*._shared_pool_reserved_min_alloc=100
*._shared_pool_reserved_pct=15
*.shared_pool_reserved_size=62914560
--注意:STRINGS后的文件要清除产生文件无关的条目
[ora10g@seconary dbs]$ strings spfileora10g.ora>initora10g.ora


*._shared_pool_reserved_min_alloc=4400


SQL> startup nomount pfile=‘/home/ora10g/product/10.2.0/db_1/dbs/initora10g.ora‘
ORA-32006: PARALLEL_AUTOMATIC_TUNING initialization parameter has been deprecated
ORACLE instance started.


Total System Global Area 1157627904 bytes
Fixed Size                  2095800 bytes
Variable Size            1040188744 bytes
Database Buffers           83886080 bytes
Redo Buffers               31457280 bytes
SQL> create spfile from  pfile=‘/home/ora10g/product/10.2.0/db_1/dbs/initora10g.ora‘
  2  ;


File created.


SQL> shutdown immediate
ORA-01507: database not mounted




ORACLE instance shut down.
SQL> startup
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.


Total System Global Area 1157627904 bytes
Fixed Size                  2095800 bytes
Variable Size            1040188744 bytes
Database Buffers           83886080 bytes
Redo Buffers               31457280 bytes
Database mounted.
Database opened.



---可见大小48字节已在保留区中分配的CHUNK
SQL> select * from  x$ksmspr where KSMCHSIZ=48;


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002AF0A3240938          0          1 reserved stoppe  000000009C451FD0         48 R-freea           0 00
00002AF0A3240888          2          1 reserved stoppe  000000009C000058         48 R-freea           0 00
00002AF0A3240830          3          1 reserved stoppe  000000009D451FD0         48 R-freea           0 00
00002AF0A3240780          5          1 reserved stoppe  000000009D000058         48 R-freea           0 00
00002AF0A3240728          6          1 reserved stoppe  00000000A3451FD0         48 R-freea           0 00
00002AF0A3240678          8          1 reserved stoppe  00000000A3000058         48 R-freea           0 00
00002AF0A3240620          9          1 reserved stoppe  00000000A4451FD0         48 R-freea           0 00
00002AF0A3240570         11          1 reserved stoppe  00000000A4000058         48 R-freea           0 00
00002AF0A3240518         12          1 reserved stoppe  00000000A2451FD0         48 R-freea           0 00
00002AF0A3240468         14          1 reserved stoppe  00000000A2000058         48 R-freea           0 00
00002AF0A3240410         15          1 reserved stoppe  00000000A1451FD0         48 R-freea           0 00


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002AF0A3240360         17          1 reserved stoppe  00000000A1000058         48 R-freea           0 00
00002AF0A3240308         18          1 reserved stoppe  00000000A0451FD0         48 R-freea           0 00
00002AF0A3240258         20          1 reserved stoppe  00000000A0000058         48 R-freea           0 00
00002AF0A3240200         21          1 reserved stoppe  000000009F451FD0         48 R-freea           0 00
00002AF0A3240150         23          1 reserved stoppe  000000009F000058         48 R-freea           0 00
00002AF0A32400F8         24          1 reserved stoppe  000000009E451FD0         48 R-freea           0 00
00002AF0A3240048         26          1 reserved stoppe  000000009E000058         48 R-freea           0 00


18 rows selected.




可以用heapdump 12级进行转储,刚好与上述x$ksmspr的条目相同
SQL> oradebug setmypid
Statement processed.
SQL> oradebug dump heapdump 12
ORA-00085: current call does not exist
SQL> oradebug dump heapdump 6
Statement processed.
SQL> oradebug tracefile_name
/home/ora10g/admin/ora10g/udump/ora10g_ora_4300.trc


SQL> host more /home/ora10g/admin/ora10g/udump/ora10g_ora_4300.trc|grep reserved
 reserved granule count 5 (granule size 16777216)
 reserved granules for root 5 (granule size 16777216)
  Chunk        09e000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09e451fd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09f000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09f451fd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a0000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a0451fd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a1000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a1451fd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a2000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a2451fd0 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a4000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a4451fd0 sz=       48  R-freeable  "reserved stoppe"
Total reserved free space   = 27179952
 reserved granules for root 5 (granule size 16777216)
  Chunk        0a3000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        0a3451fd0 sz=       48  R-freeable  "reserved stoppe"
Total reserved free space   =  4529992
 reserved granules for root 5 (granule size 16777216)
  Chunk        09d000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09d451fd0 sz=       48  R-freeable  "reserved stoppe"
Total reserved free space   =  4529992
 reserved granules for root 5 (granule size 16777216)
  Chunk        09c000058 sz=       48  R-freeable  "reserved stoppe"
  Chunk        09c451fd0 sz=       48  R-freeable  "reserved stoppe"
Total reserved free space   =  4529992




我们需要知道
经过在UE进行查找分析比对,可见
技术图片



x$ksmspr显示为标黄的内容,即KSMCHCLS=R-freea ,对应DUMP中的状态为R-freeable,这部分内存对应reserved stoppe
而reserved free list中的chunk对应ksmchlcs=R-free,且这部分内存可以自由分配
RESERVED FREE LISTS:
 Reserved bucket 0 size=32
 Reserved bucket 1 size=4400
 Reserved bucket 2 size=8216
 Reserved bucket 3 size=8696
 Reserved bucket 4 size=8704
 Reserved bucket 5 size=8712
 Reserved bucket 6 size=8720
 Reserved bucket 7 size=9368
 Reserved bucket 8 size=9376
 Reserved bucket 9 size=12352
 Reserved bucket 10 size=12360
 Reserved bucket 11 size=16408
 Reserved bucket 12 size=32792
 Reserved bucket 13 size=65560
  Chunk        09e000088 sz=  4529992  R-free      "               "
  Chunk        09f000088 sz=  4529992  R-free      "               "
  Chunk        0a0000088 sz=  4529992  R-free      "               "
  Chunk        0a1000088 sz=  4529992  R-free      "               "
  Chunk        0a2000088 sz=  4529992  R-free      "               "
  Chunk        0a4000088 sz=  4529992  R-free      "               "
Total reserved free space   = 27179952


--可见4529992字节对应的CHUNK即未在保理区分配的内存CHUNK
SQL> select * from  x$ksmspr where KSMCHSIZ=4529992;


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002B8C55D385F0          1          1 free memory      000000009C000088    4529992 R-free            0 00
00002B8C55D384E8          4          1 free memory      000000009B000088    4529992 R-free            0 00
00002B8C55D383E0          7          1 free memory      000000009D000088    4529992 R-free            0 00
00002B8C55D382D8         10          1 free memory      00000000A3000088    4529992 R-free            0 00
00002B8C55D381D0         13          1 free memory      00000000A4000088    4529992 R-free            0 00
00002B8C55D380C8         16          1 free memory      00000000A2000088    4529992 R-free            0 00
00002B8C55D37FC0         19          1 free memory      00000000A1000088    4529992 R-free            0 00
00002B8C55D37EB8         22          1 free memory      00000000A0000088    4529992 R-free            0 00
00002B8C55D37DB0         25          1 free memory      000000009F000088    4529992 R-free            0 00
00002B8C55D37CA8         28          1 free memory      000000009E000088    4529992 R-free            0 00


10 rows selected.




可见用于保留区的有2种不同的大小,1个为4529992字节,1个为48字节
SQL> select ksmchsiz,count(*) from x$ksmspr group by ksmchsiz;


  KSMCHSIZ   COUNT(*)
---------- ----------
   4529992         10
        48         20

而且x$ksmsp是x$ksmspr的父集,即前者包含后者
SQL> select * from  x$ksmspr where ksmchcom=‘free memory‘;


ADDR                   INDX    INST_ID KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002B8C55D381D8          1          1 free memory      000000009C000088    4529992 R-free            0 00
00002B8C55D380D0          4          1 free memory      000000009B000088    4529992 R-free            0 00
00002B8C55D37FC8          7          1 free memory      000000009D000088    4529992 R-free            0 00
00002B8C55D37EC0         10          1 free memory      00000000A3000088    4529992 R-free            0 00
00002B8C55D37DB8         13          1 free memory      00000000A4000088    4529992 R-free            0 00
00002B8C55D37CB0         16          1 free memory      00000000A2000088    4529992 R-free            0 00
00002B8C55D37BA8         19          1 free memory      00000000A1000088    4529992 R-free            0 00
00002B8C55D37AA0         22          1 free memory      00000000A0000088    4529992 R-free            0 00
00002B8C55D37998         25          1 free memory      000000009F000088    4529992 R-free            0 00
00002B8C55D37890         28          1 free memory      000000009E000088    4529992 R-free            0 00


10 rows selected.


SQL> select * from x$ksmsp where rownum<=10;


ADDR                   INDX    INST_ID   KSMCHIDX   KSMCHDUR KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002B8C55F75E00          0          1          1          4 sql area         000000009CFFF000       4096 recr           4095 000000009DDD38C8
00002B8C55F75DA8          1          1          1          4 KGLS heap        000000009CFFEBA8       1112 recr           4095 000000009DFFDC48
00002B8C55F75D50          2          1          1          4 sql area         000000009CFFDBA8       4096 recr           4095 000000009DFF5EF0
00002B8C55F75CF8          3          1          1          4 KGLS heap        000000009CFFD750       1112 freeabl           0 000000009DFE5520
00002B8C55F75CA0          4          1          1          4 sql area         000000009CFFC750       4096 recr           4095 000000009DF578B8
00002B8C55F75C48          5          1          1          4 free memory      000000009CFFC6E8        104 free              0 00
00002B8C55F75BF0          6          1          1          4 KGLS heap        000000009CFFC290       1112 freeabl           0 000000009DF91C68
00002B8C55F75B98          7          1          1          4 KGLS heap        000000009CFFBE38       1112 recr           4095 000000009DF9B018
00002B8C55F75B40          8          1          1          4 repository       000000009CFFBBA8        656 freeabl           0 000000009DF72CF0
00002B8C55F75AE8          9          1          1          4 KGLS heap        000000009CFFB750       1112 freeabl           0 000000009DFE36B8


10 rows selected.


SQL> select * from x$ksmsp where rownum<=10 and ksmchptr=‘000000009C000088‘;


ADDR                   INDX    INST_ID   KSMCHIDX   KSMCHDUR KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002B8C55F00498       4638          1          1          4 free memory      000000009C000088    4529992 R-free            0 00


SQL> select * from x$ksmsp where rownum<=10 and ksmchptr=‘000000009F000088‘;


ADDR                   INDX    INST_ID   KSMCHIDX   KSMCHDUR KSMCHCOM         KSMCHPTR           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00002B8C55D35638      21128          1          1          1 free memory      000000009F000088    4529992 R-free            0 00

以上是关于基于参数shared_pool_reserved_size进一步理解共享池shared pool原理的主要内容,如果未能解决你的问题,请参考以下文章

阶段3 2.Spring_07.银行转账案例_9 基于子类的动态代理

基于Flask框架搭建视频网站的学习日志

韦东山嵌入式Linux视频教程_3期项目实战之ALSA声卡_从零编写之参数设置(基于优龙FS2410开发板,UDA1341声卡)

基于gtid的备份_恢复_注意事项_mysqldump_skip-gtids_include-gtids_exclude-gtids

01:JAVA_四则运算题目生成程序(基于控制台)

01:JAVA_四则运算题目生成程序(基于控制台)