共享池記憶體分配和錯誤ORA-00371
不論是sga自動管理還是手動管理,共享池都是由2部分記憶體組成的,一部分是供我們使用者使用,這部分就是我們熟悉的library cache和dictionary cache,另一部分就是oracle內部使用的,比如引數process的大小直接決定了使用這部分內部使用的記憶體大小。
[@more@]Specifying the Shared Pool Size
The SHARED_POOL_SIZE
initialization parameter is a dynamic parameter that lets you specify or adjust the size of the shared pool component of the SGA. Oracle Database selects an appropriate default value.
In releases before Oracle Database 10g Release 1, the amount of shared pool memory that was allocated was equal to the value of the SHARED_POOL_SIZE
initialization parameter plus the amount of internal SGA overhead computed during instance startup. The internal SGA overhead refers to memory that is allocated by Oracle during startup, based on the values of several other initialization parameters. This memory is used to maintain state for different server components in the SGA. For example, if the SHARED_POOL_SIZE
parameter is set to 64MB and the internal SGA overhead is computed to be 12MB, the real size of shared pool in the SGA is 64+12=76MB, although the value of the SHARED_POOL_SIZE
parameter is still displayed as 64MB.Starting with Oracle Database 10g Release 1, the size of internal SGA overhead is included in the user-specified value of SHARED_POOL_SIZE
. In other words, if you are not using the automatic shared memory management feature, then the amount of shared pool memory that is allocated at startup is exactly equal to the value of SHARED_POOL_SIZE
initialization parameter. In manual SGA mode, this parameter must be set so that it includes the internal SGA overhead in addition to the desired value of shared pool size. In the previous example, if the S
HARED_POOL_SIZE
parameter is set to 64MB at startup, then the available shared pool after startup is 64-12=52MB, assuming the value of internal SGA overhead remains unchanged. In order to maintain an effective value of 64MB for shared pool memory after startup, you must set the SHARED_POOL_SIZE
parameter to 64+12=76MB.
The Oracle Database 10g migration utilities recommend a new value for this parameter based on the value of internal SGA overhead in the pre-upgrade environment and based on the old value of this parameter. In Oracle Database 10g, the exact value of internal SGA overhead, also known as startup overhead in the shared pool, can be queried from the V$SGAINFO
view. Also, in manual SGA mode, if the user-specified value of SHARED_POOL_SIZE
is too small to accommodate even the requirements of internal SGA overhead, then Oracle generates an ORA-371 error during startup, along with a suggested value to use for the SHARED_POOL_SIZE
parameter.When you use automatic shared memory management in Oracle Database 10g, the shared pool is automatically tuned, and an ORA-371 error would not be generated by Oracle.
--===================================
SQL> show parameter shared
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
max_shared_servers integer
shared_memory_address integer 0
shared_pool_reserved_size big integer 4823449
shared_pool_size big integer 92M
shared_server_sessions integer
shared_servers integer 0
SQL> show parameter sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 160M
sga_target big integer 160M
SQL> col name format a40
SQL> set linesize 200
SQL> select * from V$SGAINFO ;
NAME BYTES RES
---------------------------------------- ---------- ---
Fixed SGA Size 1247876 No
Redo Buffers 7139328 No
Buffer Cache Size 41943040 Yes
Shared Pool Size 96468992 Yes
Large Pool Size 16777216 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 167772160 No
Startup overhead in Shared Pool 41943040 No
Free SGA Memory Available 0
11 rows selected.
SQL> show parameter sga_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_target big integer 160M
SQL> show parameter shared_pool_size
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
shared_pool_size big integer 92M
SQL> alter system set sga_target=0;
System altered.
alter system set shared_pool_size=24m
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-04034: unable to shrink pool to specified size
SQL> alter system set shared_pool_size=24m scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00371: not enough shared pool memory, should be atleast 77298483 bytes
SQL>
--====================================
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247876 bytes
Variable Size 117441916 bytes
Database Buffers 41943040 bytes
Redo Buffers 7139328 bytes
Database mounted.
Database opened.
SQL> col name format a40
SQL> set linesize 200
SQL> select * from V$SGAINFO ;
NAME BYTES RES
---------------------------------------- ---------- ---
Fixed SGA Size 1247876 No
Redo Buffers 7139328 No
Buffer Cache Size 41943040 Yes
Shared Pool Size 96468992 Yes
Large Pool Size 16777216 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 167772160 No
Startup overhead in Shared Pool 41943040 No
Free SGA Memory Available 0
11 rows selected.
SQL> show parameter process
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0
db_writer_processes integer 4
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 150
SQL> alter system set processes=300 scope=spfile;
alter system set processes=300 scope=spfile
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE specified at startup
--由於沒有使用spfile啟動,所以上面出現了錯誤,手動編輯initSID.ora檔案,設定processes=300...
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247876 bytes
Variable Size 117441916 bytes
Database Buffers 41943040 bytes
Redo Buffers 7139328 bytes
Database mounted.
Database opened.
SQL> show parameter process
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0
db_writer_processes integer 4
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 300
SQL> col name format a40
SQL> set linesize 200
SQL> select * from V$SGAINFO ;
NAME BYTES RES
---------------------------------------- ---------- ---
Fixed SGA Size 1247876 No
Redo Buffers 7139328 No
Buffer Cache Size 41943040 Yes
Shared Pool Size 96468992 Yes
Large Pool Size 16777216 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 167772160 No
Startup overhead in Shared Pool 50331648 No
Free SGA Memory Available 0
11 rows selected.
SQL>
--把引數processes從150修改為300之後,很顯然oracle內部使用的共享池記憶體Startup overhead in Shared Pool又原來的41943040增加為50331648:
SQL> select (50331648 - 41943040)/(300 - 150) from dual;
(50331648-41943040)/(300-150)
-----------------------------
55924.0533
SQL>
oracle為每一個程式大約預留了56k的記憶體,這也是我們常說的processes引數不能設定太大的原因,設定的太大會浪費記憶體不說而且甚至導致例項無法啟動的原因。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1048062/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 9i出現記憶體分配錯誤記憶體
- 關於c語言記憶體分配,malloc,free,和段錯誤,記憶體洩露C語言記憶體洩露
- 【日常小記】記憶體分配方式及常見錯誤記憶體
- Pooled Allocation(池式分配)例項——Keil 記憶體管理記憶體
- Oracle的記憶體分配和使用Oracle記憶體
- 簡單理解動態記憶體分配和靜態記憶體分配的區別記憶體
- 關於記憶體錯誤記憶體
- JavaScript記憶體分配JavaScript記憶體
- JVM記憶體分配JVM記憶體
- java記憶體分配Java記憶體
- linux記憶體管理(一)實體記憶體的組織和記憶體分配Linux記憶體
- JVM垃圾回收和記憶體分配策略JVM記憶體
- Go記憶體分配和GC的理解Go記憶體GC
- 垃圾收集器與記憶體分配策略_記憶體分配策略記憶體
- 共享記憶體記憶體
- JVM 記憶體模型 記憶體分配,JVM鎖JVM記憶體模型
- Flume記憶體溢位錯誤記憶體溢位
- MySQL記憶體管理,記憶體分配器和作業系統MySql記憶體作業系統
- Oracle記憶體分配中的子池(Subpool)--ORA-04031Oracle記憶體
- 探索iOS記憶體分配iOS記憶體
- Java 記憶體分配策略Java記憶體
- java jvm 記憶體分配JavaJVM記憶體
- [C++]記憶體分配C++記憶體
- 動態記憶體分配記憶體
- oracle 記憶體分配和調優 總結Oracle記憶體
- Golang 共享記憶體Golang記憶體
- POSIX共享記憶體記憶體
- oracle 共享記憶體Oracle記憶體
- POSIX 共享記憶體記憶體
- ORA-04031:無法分配 32 位元組的共享記憶體記憶體
- 記憶體拷貝引起的錯誤記憶體
- eclispe 出現超記憶體錯誤Lisp記憶體
- java基礎-記憶體分配Java記憶體
- C語言-記憶體分配C語言記憶體
- java-方法記憶體分配Java記憶體
- go記憶體分配器Go記憶體
- Java 堆疊記憶體分配Java記憶體
- 記憶體分配策略學習記憶體