This is not entirely normal - the scale of the flush
is a little extreme, and ties in with your earlier
question about "session param values".
The reply you got about increasing the reserved
shared pool was correct, and is probably relevant
in this case as well.
The sequence of events for allocating memory from
the shared pool is:
Request chunk in shared pool
if no available free chunks large enough
if chunksize > 'reserved pool min alloc' (ca. 4400 bytes)
search reserved pool for large enough free chunk
if space available,
allocate in reserved pool
-- get here if
(a) reserved pool has no free space
(b) reserved pool was not checked
detach some items from end of library cache LRU
distribute items to shared pool free list - coalescing where possible
check for large enough chunk on free list
return if allocation succeeds
There may be a limit on the number of times round the loop -
but I've seen highly concurrent OLTP systems flush several
hundred megabytes from the library cache - hammering the
library cache and shared pool latches to death for seconds
at a time doing this.
You can get problems on well-designed systems with large numbers
of users because (a) the free memory eventually degrades into lots of
very small pieces, (b) the session param values is about 22 KB and
(c) the default of 5% for the reserved pool may not be enough.
As a rough guide line, if you are seeing catastrophic memory thrashing,
check that your shared_pool_reserved is about 25KB * sessions plus
a few MB. (A query against x$ksmspr will tell you how much of the
memory is used for things other than session parameters), and that's
at least the size you need for the "few MB extra").
select sum(KSMCHSIZ) from x$ksmspr
where ksmchcom not in ('free memory','session param valu')
(Don't try this against x$ksmsp, the shared pool, it could
cripple your system for anything up to a couple of minutes
if it's a system with a large shared pool and lots of users).
(the session parameter component has a couple of changes
in its name across Oracle versions).
You could also check to see how many of your session's
have got their parameters into the reserved pool - this is
quite a nice query, and not too aggressive as a more
group by ksmchcom;
(again - DON'T run it against x$ksmsp).
The Co-operative Oracle Users' FAQ
Cost Based Oracle: Fundamentals
Public Appearances - schedule updated 2nd Feb 2006
----- Original Message -----
From: "Hameed, Amir" <Amir.Hameed@(protected)>
Sent: Wednesday, February 08, 2006 5:38 PM
Subject: RE: SGA Free memory
This is normal behavior as chunks are flushed from and added to the
shared pool, the memory fluctuates. As long as you are not seeingORA-04031
error or contention on the shared pool latch is not too high,
you are fine. What RDBMS version are you on?
Sent: Wednesday, February 08, 2006 12:28 PM
Subject: Re: SGA Free memory
I am watching the usage of the SGA on my database via the following
select to_char(sysdate,'mm-dd-yyyy hh24:mi:ss'), name, bytes/(1024*1024)
from v$sgastat, dual
where pool like '%shared%' and name = 'free memory' order by bytes asc
I am running it every 10 seconds. Recently I saw the free memory going
25M to 145M over the course
of 10 sec. I'm wondering what could have caused it. Would appreciate any