Troubleshooting and Di…
来源:互联网 发布:saas软件推广 编辑:程序博客网 时间:2024/06/07 20:38
ID
In thisDocument
Applies to:
Oracle Database - Enterprise Edition - Version 8.1.5.0 to 11.2.0.4[Release 8.1.5 to 11.2]Information in this document applies to any platform.
Purpose
This article is intended to
-
help the reader understand causes of theORA-4031 -
gather the diagnosticsneeded to narrow down the errors -
answer some of the commonquestions asked about ORA-4031
Last updated June 2010
Video - FAQ for ORA-4031 Errors (08:00)
Common Bugs
Review Note: 4031.1 for latest bug information searchable by releaselevel.
NOTE:
Questions andAnswers
How is memory allocated and deallocated in the SGApools?
The SGA is comprised of fixed areas like the Log Buffers and theBuffer Cache(s)
This is similarto
Inside these pools, we use
To get a better idea, see this information from a heapdump traceshowing the free list bucket summary:
Free List Bucket Summary :
Bucket 0 [size=32 ] Count= 0 Av.Size= 0.00 Max= 0
Bucket 1 [size=40 ] Count= 443 Av.Size= 40.00 Max= 40
Bucket 2 [size=48 ] Count= 1850 Av.Size= 48.00 Max= 48
This shows that bucket 1 has 443 chunks of memory where the maximumsize is 40 bytes and the average is 40 bytes. Bucket 2 is a freelist of memory chunks with sizes between 40 and 48 bytes. When achunk of space is freed/deallocated, it is added to the bucketwhose size is less than or equal to the chunksize.
The Shared Pool and LargePool divide their shared memory areas intosubpools
When a memory chunk isallocated inside the memory pool, it will be associated with amemory type.
Chunk types:
Normal (freeable) chunks - These chunks are allocated in such a waythat the user can explicitly free
the chunk once they have finished with the memory.
Free chunks - These chunks are free and available for reuse shoulda request come into the pool for
this chunk size or smaller.
Recreatable chunks - This is a special form of "freeable"memory.
LRU list when they areunpinned.
memory that hasn't been used for a while.
Permanent chunks - These chunks can be allocated in differentways.
and will remain in use for the "life" of theinstance.
be used over and over again internally as they areavailable.
@
@
What are Subpools?
In Oracle 9i and later versions, the SharedPool
When you get an ORA-04031, the trace will indicate the subpoolwhere the error occurred.
For example,
ORA-04031: unable to allocate 4192 bytes of shared memory ("sharedpool","SELECT * F...","sql area (6,0)","kafco :qkacol"):4031:375:2008:ocicon.c
In this case, the sixth subpool is where the error occurred
The downside to using subpools is that there are cases where onesubpool can get over-utilized. Once the subpool is selected, thesearch for memory chunks can fail even though another subpool mighthave adequate memory available. Starting with 10g, wedo have functionality allowing the search to"switch" to another subpool if a memory request is not met in theselected subpool but that is not
@
@
@
@
@
Unbalanced use of the subpools can lead toORA-04031.
An end-user has no visibility into subpools.
Reference (this problem appears to have spanned many bugs):
Bug 4184298 - Subpool imbalance for "sessionparameters"
What is the Reserved Area?
A cache miss on the data dictionary cache or library cache ismore expensive than a miss on the buffer cache.
to be flushed to make room for the large space requests.
By default, Oracle configures a small Reserved Pool (or ReservedArea) inside the Shared Pool. This memory can be used to satisifylarge contiguous allocation requests when space is not available inthe general shared pool list.
These large allocation requests are typically for operations suchas PL/SQL and trigger compilation or for temporary space whileloading Java objects.
After the memory allocated from the Reserved Pool is freed, itreturns to the Reserved Pool.
The minimum size of allocations that can be placed in Reserved poolare controlled via hidden parameter_shared_pool_reserved_min_alloc. The default setting is 4400 byteson recent versions and can be set as low as 4000 bytes.
Memory allocation requests larger than value of_shared_pool_reserved_min_alloc can allocate space from thereserved list if a chunk of memory of sufficient size is not foundon the general shared pool free list.
IF the failing size as indicated by the ORA-4031 error messages orLAST_FAILURE_SIZE column ofV$SHARED_POOL_RESERVED
that is an indication the Reserved area needs to be increased toaccommodate these large space requests.
The Reserved pool size can be set to a fixed size by specifyingshared_pool_reserved_size or as a percentage with hidden parameter_shared_pool_reserved_pct.
By default, 5% of the
select a.ksppinm "Parameter",
b.ksppstvl "Session Value",
c.ksppstvl "Instance Value"
from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c
where a.indx = b.indx and a.indx = c.indx
and a.ksppinm in('_shared_pool_reserved_pct','_shared_pool_reserved_min_alloc');
to see the current settingin your environment.
The viewV$SHARED_POOL_RESERVED can be used to determine failed requestsizes and shared pool reserved areautilization.
Warning:
If you decide to use theSHARED_POOL_RESERVED_SIZE parameter and SGA_TARGET>0, you mayexperience ORA-4031 situations on large memory requests because theMMAN process may be increasing the size of the Shared Pool overtime, while the Reserved Area remainsconstant.
The Reserved Area handles
SQL> alter system set"_shared_pool_reserved_pct"=10 scope=spfile
or add this in the pfile
"_shared_pool_reserved_pct"=10
For large allocations,Oracle attempts to allocate space in the Shared Pool in thefollowing order:
What are the pools in the SGA usedfor?
The Shared Pool portion ofthe SGA contains the library cache, the dictionary cache, buffersfor parallel execution messages, and controlstructures.
Many features ofOracle
The Java Pool memory isused
If using Streamsfunctionality, you can configure the Streams Pool to manage memoryallocations needed for this functionality.
The Shared Pool employsa
The
What is an ORA-04031 Error?
The memory pool in the SGAare comprised of memory chunks in various sizes. When the databasestarts is started, you have a large chunk of memory allocated inthe various pools and tracked in free list hash buckets. Over time,as memory is allocated and deallocated, the memory chunks are movedaround into different free list buckets inside the pool accordingto their size. An ORA-04031 error occurs in any of the memory poolsin the SGA when Oracle cannot find a memory chunk large enough tosatisfy an internal allocation request on behalf of a user'soperation.
The Shared Pool is
scan regular free list formatch, if not found
NOTE:
The sum of the free space, which one may obtain through v$sgastator x$ksmsp, is not important. What is important is the size of thelargest chunk that can be freed or merged after some LRUoperations.
Free List Bucket Summary :
Bucket 0 [size=32 ] Count= 0 Av.Size= 0.00 Max= 0
Bucket 1 [size=40 ] Count= 443 Av.Size= 40.00 Max= 40
Bucket 2 [size=48 ] Count= 1850 Av.Size= 48.00 Max= 48
This shows that bucket 1 has 443 chunks of memory where the maximumsize is 40 bytes and the average is 40 bytes. Bucket 2 includesmemory chunks with sizes between 40 and 48 bytes.
The 4031 error can occur in the Large Pool, Java Pool, Streams Pool(new to 10g), or the Shared Pool.
The Shared Pool is little more complicated to tune. Forexample
ORA-04031: unable to allocate 4192 bytes of shared memory ("sharedpool","SELECT * F...","sql area","kafco :qkacol"):4031:375:2008:ocicon.c
In this case, the problem occurred in the Shared Pool. The errormessage also includes information on the size of the memory requestthat failed. In our example, the failure was on a request for 4192bytes in the SQL Area.
NOTE:
Note 146599.1 Diagnosing and Resolving Error ORA-04031
Is my Reserved Area sizedproperly?
An ORA-04031 error referencing a large failed requests indicatesthe Reserved Area is toofragmented.
ReservedAnalysis.sql
Request Misses = 0 can mean the Reserved Area is toobig. Request Misses alwaysincreasing but Request Failures not increasing can mean theReserved Area is too small. In this case flushesin the Shared Pool satisfied the memoryneeds. Request Misses andRequest Failures always increasing can mean the Reserved Area istoo small and flushes in the Shared Pool are not helping (likelygot an ORA-04031).
You can also investigate the
col requests for 999,999,999
col last_failure_size for 999,999,999 head "LAST FAILURE| SIZE"
col last_miss_size for 999,999,999 head "LAST MISS|SIZE "
col pct for 999 head "HIT|% "
col request_failures for 999,999,999,999 head "FAILURES"
select requests,
decode(requests,0,0,trunc(100-(100*(request_misses/requests)),0))PCT, request_failures, last_miss_size, last_failure_size
from v$shared_pool_reserved;
The
select p.inst_id, p.free_space, p.avg_free_size,p.free_count,
p.max_free_size, p.used_space, p.avg_used_size,p.used_count, p.max_used_size,
s.requests, s.request_misses, s.last_miss_size,s.max_miss_size,
s.request_failures, s.last_failure_size,s.aborted_request_threshold,
s.aborted_requests, s.last_aborted_size
from (select avg(x$ksmspr.inst_id)inst_id,
sum(decode(ksmchcls,'R-free',ksmchsiz,0))free_space,
avg(decode(ksmchcls,'R-free',ksmchsiz,0))avg_free_size,
sum(decode(ksmchcls,'R-free',1,0))free_count,
max(decode(ksmchcls,'R-free',ksmchsiz,0))max_free_size,
sum(decode(ksmchcls,'R-free',0,ksmchsiz))used_space,
avg(decode(ksmchcls,'R-free',0,ksmchsiz))avg_used_size,
sum(decode(ksmchcls,'R-free',0,1))used_count,
max(decode(ksmchcls,'R-free',0,ksmchsiz))max_used_size from x$ksmspr
where ksmchcom not like '%reserved sto%')p,
(selectsum(kghlurcn) requests, sum(kghlurmi)request_misses,
max(kghlurmz)last_miss_size, max(kghlurmx)max_miss_size,
sum(kghlunfu)request_failures, max(kghlunfs) last_failure_size,
max(kghlumxa) aborted_request_threshold, sum(kghlumer)aborted_requests,
max(kghlumes) last_aborted_size from x$kghlu) s;
Is there a way to find a "right" size for the SharedPool?
You can configure the Shared Pool manually using theSHARED_POOL_SIZE parameter or have the pool auto-tuned usingSGA_TARGET (10g and higher).
Example,
SHARED_POOL_SIZE=64M
Overhead=12M
SQL> Select sum(bytes) "Total Mem" from v$sgastat wherepool='shared pool';
Total Mem
-----------
79691776
With 10g, this overhead memory is now included inside theSHARED_POOL_SIZE setting.
NOTE: Scripts like
Note 270935.1 Shared pool sizing in 10g
Note 430473.1 ORA-4031 Common Analysis/Diagnostic Scripts
How much free memory is available in my SGA?
You can see the free memory for the Shared Pool in the viewV$SGASTAT. The view is broken down into memory structure tableentries like 'library cache', 'KGLS heap', 'CCursor'. Prior to 10g,there were only a handful of table entries tracked in this view sosmall memory structures were lumped together in the table entry'miscellaneous'.
The X$KSMSP view shows the breakdown of memory in theSGA.
SQL> SELECT KSMCHCLSCLASS, COUNT(KSMCHCLS) NUM, SUM(KSMCHSIZ) SIZ,
To_char( ((SUM(KSMCHSIZ)/COUNT(KSMCHCLS)/1024)),'999,999.00')||'k'"AVG SIZE"
FROM X$KSMSP GROUP BY KSMCHCLS;
CLASS NUM SIZ AVG SIZE
-------- ---------- ---------- ------------
R-free 12 8059200 655.86k< processing
perm 2 30765848 15,022.39k< system
recr 3577 3248864 .89k< processing
**SAFER APPROACH ON SOME VERSIONS OF 11g**
select DSIDX_KSMNWEX "DSIDX",CURDUR_KSMNWEX "DURATION",
from X$KSMSP_NWEX
group by DSIDX_KSMNWEX, CURDUR_KSMNWEX
order by DSIDX_KSMNWEX, CURDUR_KSMNWEX;
Watch for trends using these guidelines:
a) if 'free' memory (column SIZ) is low (less than 5mb or so)you may need to increase the shared_pool_size andshared_pool_reserved_size.
b) if 'freeable' or 'perm' memory (columnSIZ)
c) if 'freeabl' and 'recr' memory classes
d) if 'free' memory
NOTE: Please be aware that there are bugs filed on HP indicatingrunning queries on x$ksmsp can hang the system on 10g. I haven'tseen reports of the problem on 9.2.x or on otherplatforms.
What is managed automatically through 10g ASMMand/or 11g AMM?
The Automatic Shared Memory Management functionality is "turnedon" when SGA_TARGET>0 on Release 10g.
-
SharedPool -
LargePool -
Java Pool -
Buffer Cache (the defaultone managed by db_cache_size) -
Streams Pool (new to 10gRelease 2)
Memory is moved in "granule sized" chunks.
The other buffer caches (managed through parametersDB_nK_CACHE_SIZE,
The SGA_TARGET can be changed dynamically up to the setting forSGA_MAX_SIZE.
Case Study:
You configured SGA_TARGET to be 4G.
You also configure
DB_KEEP_CACHE_SIZE=256M
LOG_BUFFER=200M
DB_4K_CACHE_SIZE=512M.
You also
How does this affect MMAN?
Per the configuration above,
+ SharedPool
------------------------------------
Total
There
SGAComponents11g.sql (for 11g)
A rule of thumb for setting up ASMM is
SGA_TARGET = 256M * # of CPUs
This makes a lot of assumptions about your application memoryusages, etc. and it may be more appropriate to monitor the currentsize of the managed pools the queries listed above
1.
2.
3.
4.
Warning:
Starting with 11g, auto-tuning manages PGA_AGGREGATE_TARGET aswell.
NOTE:
@INTERNAL ONLY:
@If it becomes necessary to gather trace dataassociated with memory allocation by ASMM,
@ you can use
@
@ SQL> ALTER SYSTEM SET"_memory_management_tracing"=7;
@
@ This will trace dynamic memory allocations. Itmay well cause the alert log
@ to grow quickly get the diagnostic data for afew hours or a typical day at most.
@ Then reset the event (to 0).
@
@ SQL> ALTER SYSTEM SET"_memory_management_tracing"=0;
@
@ Generally this should only be used wheninstructed to do so by development.
How many Subpools will I have by default?
The number of subpools iscalculated using a simple algorithm.
If someone configured a 12-CPU system with a300MB shared pool on 9i,
Because 128MB (and even256MB on 10g) subpools
Change as of 10.2.0.3 andhigher:
How do I control the number of subpools used?
To see the number ofsubpools used currently issue
select a.ksppinm "Parameter",
b.ksppstvl "Session Value",
c.ksppstvl "Instance Value"
from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c
where a.indx = b.indx and a.indx = c.indx
and a.ksppinm like '%kghdsidx%';
The parameter _kghdsidx_count controls the number of subpoolsused.
SQL> alter system set"_kghdsidx_count"=1scope=spfile;
or add this in the pfile
"_kghdsidx_count"=1
NOTE:
on RAC configurations, highly concurrent systems, or databaseinstance with very large pools.
Altering this parameter will affect the Shared pool, Shared poolreserved and Large pool.
Reducing the number of subpools could result in increased latchcontention in the pool area.
When setting the number of subpools manually with _kghdsidx_count,recommend making the changes
incrementally to monitor performance impact and minimize anydrastic impact.
Conversely, increasing number of subpools without increasingoverall pool size could lead
to space issues since subpools could be undersized.
Are all ORA-04031 errors reported in the alertlog?
No.
NOTE:
You can
From website http://www.ixora.com.au/
connect / as sysdba
-------------------------------------------------------------------------------
--
-- Script: shared_pool_lru_stats.sql
-- Purpose: to check the shared pool lru stats
-- For: 8.0 and higher
--
-- Copyright: (c) Ixora Pty Ltd
-- Author: Steve Adams
--
-- NOTE: Per Bug 3352753, this may not work with 9i and higher /added kghlushrpool to Steve's code for 9i/10g. Reports are coming in of issues with this query on 11g.
-------------------------------------------------------------------------------
>column kghluops heading "PINS AND|RELEASES"
column kghlunfu heading "ORA-4031|ERRORS"
column kghlunfs heading "LAST ERROR|SIZE"
column kghlushrpool heading"SUBPOOL"
select
kghlushrpool,
kghlurcr,
kghlutrn,
kghlufsh,
kghluops,
kghlunfu,
kghlunfs
from
sys.x$kghlu
where
inst_id = userenv('Instance')
We recommend using this code instead for 10g and higher:
col free_space format 999,999,999,999 head "Reserved|FreeSpace"
col max_free_size format 999,999,999,999 head "Reserved|Max"
col avg_free_size format 999,999,999,999 head "Reserved|Avg"
col used_space format 999,999,999,999 head "Reserved|Used"
col requests format 999,999,999,999 head "Total|Requests"
col request_misses format 999,999,999,999 head"Reserved|Area|Misses"
col last_miss_size format 999,999,999,999 head "Size of|LastMiss"
col request_failures format 9,999 head "Shared|Pool|Miss"
col last_failure_size format 999,999,999,999 head"Failed|Size"
select request_failures, last_failure_size, free_space,max_free_size, avg_free_size
from v$shared_pool_reserved
/
select used_space, requests, request_misses, last_miss_size
from v$shared_pool_reserved
/
"Shared Pool Miss" (or "Reserved Area Misses") will be incrementedwhen a request for memory fails.
How can we see a breakdown of the data in the"miscellaneous" structure in V$SGASTAT?
When running a query on v$sgastat, there are cases where youwill see a very large value for "miscellaneous".
Per bug 3663344, there were occasional inconsistencies in thestatistics reported in
The only way to "drill-down" into the way memory is allocated inthe "miscellaneous" area is to get a heapdumptrace.
alter system set events '4031 trace nameHEAPDUMP level 536870914';
NOTE: Setting this event at the instance levelwill generate large files and if the 4031 error occurs frequently,you will get many trace files. This can impactperformance and hang (and in some cases crash adatabase). Turn this event off using
alter system set events '4031 trace name HEAPDUMPoff';
and at the next occurrences of the 4031 problem you will get abreakdown of the memory in the SGA and also the breakdown of memoryused in the top five subheaps in the SGA.
To get an immediate memory dump use these steps
alter system set events 'immediate trace nameheapdump level 536870914';
or
sqlplus /nolog
connect / as sysdba
oradebug setmypid
oradebug unlimit
oradebug dump heapdump
oradebug tracefile_name
oradebug close_trace
Close the SQL*Plus session and find the heapdump trace filelisted in the 'oradebug tracefile_name' command above.
If the problem is actually associated with permanent memorystructures (tracked under the 'miscellaneous' table entry), thereis not a way to get information on these memory areasunless
@INTERNALONLY:
@ To set the 10235, it is necessary to add
@
@ event = '10235 trace name context forever, level65536'
@
@ to the pfile used to startup the database or toadd this to the spfile using
@
@ ALTER SYSTEM SET
@
@
@ The database must be restarted in both cases asthis event causes additional
@ comment information to betracked
@ structures. The level 65536
@
@ performance
@ for more on level 65536.
What database parameters are relevant to ORA-04031problems?
- CURSOR_SHARING
Literalreplacement is a feature where Oracle replaces literal values inSQL statements to reduce the application Shared Pool footprint anddecrease "hard" parsing.
For example, two users connected as
The parameter has three modes:
- EXACT: no attempt at literal replacement
- FORCE: all literals are replaced; statements are shared withoutregard for how the literal values may affect the executionplan.
- SIMILAR: all literal are replaced, but statements are sharedonly if the cursors have the same plan.
Invalidations arecaused by either executing DDL against the objects, gatheringstats, or granting/revoking privileges.
References:
Note 287059.1 Library Cache Pin/Lock Pile Up hangs theapplication
Note 34579.1
Note 115656.1 WAIT SCENARIOS REGARDING LIBRARY CACHE PIN ANDLIBRARY CACHE LOAD LOCK
The implementationof SIMILAR is not optimal.
To Gauge the effectiveness of your current setting for thisparameter, refer to Note 208918.1
- CURSOR_SPACE_FOR_TIME
If this parameteris set, Oracle does not unpin the library cache object at the endof execute.
Some sites use this parameter
NOTE:
- DB_CACHE_SIZE
Review the sizeset for the parameter in the RDA. If using SGA_TARGET, this willdefault to 0. Any hard-coded setting for this parameter when usingSGA_TARGET will act as a minimum size for MMAN when it attempts toshrink the Buffer Cache.
- DB_nK_CACHE_SIZE
This SGA memorycomponent is not auto-tuned, but the memory setting will affect theactual memory available to MMAN.
- DB_KEEP_CACHE_SIZE
This SGA memorycomponent is not auto-tuned, but the memory setting will affect theactual memory available to MMAN.
- DB_RECYCLE_CACHE_SIZE
This SGA memorycomponent is not auto-tuned, but the memory setting will affect theactual memory available to MMAN.
- JAVA_POOL_SIZE
If usingSGA_TARGET, this will default to 0. Any hard-coded setting for thisparameter when using SGA_TARGET will act as a minimum size for MMANwhen it attempts to shrink the
If you are notusing SGA_TARGET, the default size for this memory area is usuallysufficient unless your environment
@NOTE: In some cases, an ORA-04031 error will occur like
@
@ ORA-04031: unable to allocate ... bytes ofshared memory ("shared pool",
@ "unknown object", "joxlod: inith",
@
@ The third argument is JOXLOD, this indicates aproblem with the Java Pool, even though the
@ pool listed in the
@ too small.
If you need to seemore detail on how the memory is allocated in the Java Pool, youcan issue
> sqlplus /nolog
SQL> connect / as sysdba
SQL> alter session set events 'immediate trace name heapdumplevel 128';
- LARGE_POOL_SIZE
The Large Pool isintended to
If you need to see more detail on how the memory is allocated inthe Large Pool, you can issue
SQL> connect / as sysdba
SQL> alter session set events 'immediate trace name heapdumplevel 32';
If usingSGA_TARGET, the parameter will show as 0, but you can hard-code aminimum size
- LOG_BUFFER
This SGA memorycomponent is not auto-tuned, but the memory setting will affect theactual memory available to MMAN.
- OPEN_CURSORS
Thisparameter
In versions of Oracle prior to9.2.0.5,
If a user explicitly opened a cursor and the session could not opena new cursor (the number of open cursors was equal toOPEN_CURSORS), one of the cached cursor would be closed so theexplicit open would succeed.
Reference:
Note 76684.1
Note 208857.1
- PROCESSES / SESSIONS
These processeswill impact the size of the shared pool starting in 9.2.x. Memorystructures are located in the Shared Pool with 9.2.x to storedynamic parameter setting information persession/process.
- SESSION_CACHED_CURSORS
When a cursor isclosed, Oracle divorces all association between the session and thelibrary cache state. If no other session has the same cursoropened, the library cache object and its heaps are unpinned andavailable for an LRU operation. The parameterSESSION_CACHED_CURSORS controls the number of cursors "soft"closed, much like the cached PL/SQL cursors.
SESSION_CACHED_CURSORS cursors are not part of the open_cursorsstatistic; it is a separate list. Instead of being really closed,Oracle places the cursor on a session-private LRU list and keepsthe cursor available for a subsequent parse. If the user executes anew statement, it will first search the Session Cached Cursor listand, if found, uses it.
This parameter was originally conceived for Oracle FORMSapplications. To parallelize FORMS development, customers oftendeveloped separate forms and navigated from form to form. The FORMSbehavior is to close all cursors from the previous form beforenavigating to the next form. This parameter allowed Oracle to"cache" closed cursors and reused them if the application opens acursor for the same statement.
Setting this parameter to a high value increases the amount ofLibrary Cache memory (monitored by reviewing the viewV$SGASTAT).
In 9.2.0.5 onwards, this parameter has also been overloaded tocontrol the number of cursors PL/SQL caches using cursors allocatedthrough the setting for OPEN_CURSORS.
Reference:
Note 270097.1 ORA-4031 and Very Large Library Cache in Oracle9.2 with Session_cached_cursors set. Library Cache Pin/Lock Pile Uphangs the application
Note 274496.1 ORA-7445 and ORA-4031 in 9.2.0.5 and 10g ifSESSION_CACHED_CURSORS is used
- SGA_TARGET
If this parameteris set, the MMAN process will attempt to grow and shrink auto-tunedmemory components.
- SHARED_POOL_SIZE
If usingSGA_TARGET, this will default to 0, but a hard-coded setting forthis parameter will act as a minimum size for MMAN when it attemptsto shrink the Shared Pool.
Reference:
Note 270935.1 Shared pool sizing in 10g
If you need to seemore detail on how the memory is allocated in the Shared Pool, youcan issue
> sqlplus /nolog
SQL> connect / as sysdba
SQL> alter session set events 'immediate trace name heapdumplevel 2';
NOTE: Running the heapdump trace is notrecommended during peak activity on thedatabase. The tracing willaffect performance.
- SHARED_POOL_RESERVED_SIZE
This parameterdefaults to 5% of the SHARED_POOL_SIZE setting. When usingSGA_TARGET, this will be adjusted as the Shared Pool componentgrows and shrinksautomatically.
SQL> alter system set"_shared_pool_reserved_pct"=10 scope=spfile;
or add in the init file
"_shared_pool_reserved_pct"=10
- STATISTICS_LEVEL
There areadditional memory structures in 10g related to Statistics tracking.This parameter controls all major statistics collections oradvisories in the database and sets the statistics collection levelfor the database. The parameter can be set to BASIC, TYPICAL, orALL.
The defaultsetting of TYPICAL will put strain on the Shared Pool unless youtune the Shared Pool to
In some known
- STREAMS_POOL_SIZE
This is new memorypool in 10g.
If usingSGA_TARGET on 10g Release 2, the parameter will be auto-tuned andwill show up as 0.
If you need to seemore detail on how the memory is allocated in the Java Pool, youcan issue
> sqlplus /nolog
SQL> connect / as sysdba
SQL> alter session set events 'immediate trace name heapdumplevel 64';
Also review any settings that would indicate the use of SharedServer (MTS_SERVERS, MTS_DISPATCHERS, etc).
NOTE:
What should we look at in an RDA to help diagnose a4031 error?
Review the RDA report because many of the "pieces of the puzzle"or in a single report.
Under 'Overview', 'System Information', review the number ofCPUs on this server.
Under 'Overview', 'Database Information', review the releaselevel information (V$VERSION)
Under 'RDBMS', 'Database Parameters', review the appropriateparameters as described above. With the latest versions of the RDAreport, the hidden parameter settings are included in this section.You should review the settings for '_PX_use_large_pool','_kghdsidx_count', '_large_pool_min_alloc','_library_cache_advice', '_shared_pool_reserved_pct','_shared_pool_reserved_min_alloc', '_4031_dump_bitvec','_4031_max_dumps', '_4031_dump_interval','_4031_sga_dump_interval', '_4031_sga_max_dumps'.
Under 'RDBMS', 'V$RESOURCE_LIMIT', review the high water markinformation for 'processes', 'sessions'. If the settings forPROCESSES and SESSIONS is much higher than high water mark numbers,decreasing these settings could help decrease some permanent memorystructure allocations. In RAC environments, the parameter settingsfor 'ges*' parameters can also be important. There are someRAC/ORA-04031 bugs related to the 'ges%' parameters.
What is relevant in the default 4031 tracefile?
With 9.2.0.5 and higher, a trace file is generated at the timeof an ORA-04031 error (controlled by_4031_dump_bitvec).
With 10g, the default is 20479
and there are additional initialization parameters added aswell:
_4031_dump_interval (default 300) -
_4031_sga_dump_interval (default 3600) -
NOTE: Setting either of these to 0 means all errors generate atrace file.
_4031_max_dumps (default 100)
_4031_sga_max_dumps (default 10)
Be sure to check the header information and verify that the dateinformation matches up with the reports of theerrors.
*** SESSION ID:(242.24755) 2006-08-2908:55:15.765
=================================
Begin 4031 Diagnostic Information
=================================
The following information assists Oracle in diagnosing
causes of ORA-4031 errors. This trace may be disabled
by setting the init.ora parameter _4031_dump_bitvec = 0
======================================
Allocation Request Summary Information
======================================
Current information setting: 00654fff
Dump Interval=300 seconds SGA Heap Dump Interval=3600 seconds
Last Dump Time=08/29/2006 08:55:14
Allocation request for: optdef :apanlg <<<< request for memeory
structure(related to
inlistand the CBO)
Heap: 44b5c89b8, size:96 <<<******************************************************
******************************************************
HEAP DUMP heap name="sga heap" desc=380000030
extent sz=0xfe0 alt=200 het=32767 rec=9 flg=-126 opc=0
parent=0 owner=0 nex=0 xsz=0x1
******************************************************
HEAP DUMP heap name="sql area" desc=44b5c89b8 < in "sql area"
extent sz=0x1040 alt=32767 het=32 rec=0 flg=2 opc=2
parent=380000030 owner=44b5c8898 nex=0 xsz=0x1
Subheap has 840329704 bytes of memory allocated
Scroll down the trace file until just after the Stack Tracelisting,
----- End of Call Stack Trace -----
===============================
Memory Utilization of Subpool1 <===============================
Allocation Name Size
_________________________ __________
"free memory "124944864 <<<< this was "free memory" at timeof error
"miscellaneous "57893552 <<<< prior to 10gR2, this is a general purpose
holder for a lot of smaller memory areas
"sim memory hea " 2319640
"PL/SQL PPCODE " 0
"KQR L SO " 56320
"type object de " 0
"trigger source " 0
"errors " 0
"PX subheap " 147016
"trigger defini " 0
"trigger inform " 0
"PLS non-lib hp " 2088
"KGLS heap " 215352
"FileOpenBlock " 7517528
"KQR M SO " 39976
"PL/SQL SOURCE " 0
"PL/SQL DIANA " 99968
"joxlod: in phe " 0
"db_block_hash_buckets " 9978352
"joxs heap init " 4240
"MTTR advisory " 697248
"fixed allocation callback" 552
"dictionary cache " 3229952
"KQR L PO " 245784
"KQR M PO " 319096
"parameters " 0
"partitioning d " 0
"library cache " 18615496
"table definiti " 0
"sql area " 901605416 < of memory already allocated here
"pl/sql source " 0
"transaction co " 0
"KGK heap " 7000
"KQR S SO " 14360
"event statistics per sess" 12499760
"joxlod: in ehe " 357736
"temporary tabl " 0
"PL/SQL MPCODE " 39392
Scrolling down a bit more in the trace file, we see the LibraryCache information at the time of the error:
LIBRARY CACHESTATISTICS: (emphasis added on keyareas)
namespace gets hit ratio pins hit ratio reloadsinvalids
-------------- ------------------ --------- --------- ---------- ----------
CRSR 4265150 0.977 4961141500.999 155148 46115
TABL/PRCD/TYPE 40860748 0.99980409664 0.994 190813 0
BODY/TYBD 52028 0.996 55986 0.9203084 0
TRGR 468975 0.998 468975 0.99876 0
INDX 54546 0.919 65318 0.867 00
CLST 122885 0.992 166510 0.989 00
OBJE 0 0.000 0 0.000 00
In the Library Cache Statistics information, look for 'hitratio' percentages that would indicate fragmentationproblems.
On 10gR2, the V$SGASTAT
If explicitly setting the Heapdump event
alter system set events '4031 trace nameHEAPDUMP level 536870914';
you will see a more detailed view of memory
SUBHEAP 1: desc=3800092e0
******************************************************
HEAP DUMP heap name="KSFD SGA I/O b" desc=3800092e0
extent sz=0x4258 alt=32767 het=32767 rec=9 flg=3 opc=0
. . .
******************************************************
SUBHEAP 2: desc=3a1b57a10
******************************************************
HEAP DUMP heap name="PX subheap" desc=3a1b57a10
extent sz=0xff50 alt=32767 het=32767 rec=9 flg=2 opc=0
parent=380000030 owner=0 nex=0 xsz=0xff38
EXTENT 0 addr=3a4342860
Chunk 3a4342870 sz= 64904 free " "
Chunk 3a43525f8 sz= 104 freeable "PX msg batch st"
Chunk 3a4352660 sz= 104 freeable "PX msg batch st"
Chunk 3a43526c8 sz= 104 freeable "PX msg batch st"
Chunk 3a4352730 sz= 104 freeable "PX msg batch st"
Total heap size =65320
Bucket 0 size=40
Bucket 1 size=104
Bucket 2 size=528
Bucket 3 size=600
Bucket 4 size=1112
Bucket 5 size=1120
Chunk 3a4342870 sz= 64904 free " "
Total free space =64904
PERMANENT CHUNKS:
Permanent space = 0
******************************************************
In some cases, it is necessary to dump additional diagnosticinformation on a subheap.
Chunk 3a0ba0480 sz= 4184 freeable "CURSOR STATS "ds=3a1a6c0d8
. . .
ds 3a1a6c0d8 sz= 246856 ct= 59
39e642190 sz= 4184
39c08c728 sz= 4184
SQL> ORADEBUG SETMYPID
SQL> ORADEBUG DUMP HEAPDUMP_ADDR 1 15596962008 (decimal value for 3a1a6c0d8)
<>>
HEAP DUMP heap name="CURSOR STATS" desc=3a1a6c0d8
extent sz=0x1040 alt=32767 het=32767 rec=9 flg=3 opc=0
parent=380000030 owner=0 nex=0 xsz=0x1040
EXTENT 0 addr=39e6421a8
Chunk 39e6421b8 sz= 4144 free " "
EXTENT 1 addr=39c08c740
Chunk 39c08c750 sz= 80 freeable "kks pstat "
. . .
Chunk 39c08c860 sz= 336 freeable "kks cstat "
@
@ Search in TAO
@
@ It can also be necessary to run a library cachedump if the problem seems to point to
@ fragmentation issues
@
@ ALTER SYSTEM SET EVENTS IMMEDIATE TRACE NAMELIBRARY_CACHE LEVEL 11;
@
@
What is relevant in the Statspack/AWR report for a4031 error?
When investigating the 4031 problem using the Statspack/AWRreports, focus on the following
- time period
- v$librarycache statistics
- parse vs execute and parse/sec (hard vs soft parses)
- Waits section
- Parameter section
- Latch contention
Database DBId Instance InstNum StartupTime Release RAC
~~~~~~~~ ----------- ------------ -------- -------------------------- ---
1460166532 cqlwh 1 28-Nov-05 20:18 10.2.0.1.0 NO
Host Name: cqlstldb06.ceque Num CPUs: 4 Phys Memory (MB):3,992
and
Load Profile
~~~~~~~~~~~~
PerSecond Per Transaction
--------------- ---------------
Parses: 132.46 31.70
Hardparses: 0.73 0.17
Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Library Hit %:99.90 SoftParse %: 99.45
Execute to Parse %:42.77 Latch Hit %: 99.91
Parse CPU to Parse Elapsd %: 97.19 % Non-Parse CPU: 93.91
Shared PoolStatistics Begin End
------ ------
MemoryUsage %: 95.54 95.50
% SQL withexecutions>1: 71.11 67.96
- Troubleshooting and Di…
- Troubleshooting ORA-1555&nb…
- Troubleshooting ORA-27300 ORA-27…
- poj 3459 Dual Core CPU(最小割 di…
- PROCESS J000 And …
- Spring IOC/DI
- Why ASMLIB and why not? <转载…
- How to Disable and Turn Off UAC …
- Simulate and use real GPS in WM …
- How do I get default date and ti…
- HDOJ 1028 Ignatius and the Pri…
- GSM900 and GSM1800 ARFCN Frequen…
- Introduction: Using diff and pat…
- Data References and Anonymous St…
- [Flex] Hierarchical and grouped …
- Thinkpad Rescue and Recovery 使…
- Bootloader and Uboot compiled, c…
- poj 1459 power network(网络流 di…
- cannot restore segment…
- 腾讯云服务器Nginx+php+mysql环境搭建
- Linux下查询一个包是32位还是64位
- rpm -ivh elfutils-libe…
- OPP time out 问题
- Troubleshooting and Di…
- 11g: TNS-12532 / …
- tnsping通但无法连接的问题处理
- linux下如何禁用防火墙
- Can Not Allocate Log
- DLL开发与使用
- PMON failed to ac…
- PRVF-5439: NTP daemon&…
- PRVF-5439 : NTP d…