I have an Oracle 11.2.0.1 database using dynamic memory allocation with parameter MEMORY_TARGET
. When I decrease it with SCOPE=BOTH, the size of the SGA doesn't seem to decrease along with it. I have tested this on multiple systems. Here is an example
SQL> show parameter memory_target
NAME TYPE VALUE
------------------------------------ ----------- -------------------------
memory_target big integer 820M
SQL> sho sga
Total System Global Area 855982080 bytes
Fixed Size 2180544 bytes
Variable Size 520096320 bytes
Database Buffers 327155712 bytes
Redo Buffers 6549504 bytes
SQL> alter system set memory_Target=720M scope=both;
System altered.
SQL> show sga
Total System Global Area 855982080 bytes
Fixed Size 2180544 bytes
Variable Size 520096320 bytes
Database Buffers 327155712 bytes
Redo Buffers 6549504 bytes
SQL> show parameter memory_target;
NAME TYPE VALUE
------------------------------------ ----------- -------------------------
memory_target big integer 720M
SQL>
However, after I bounce the instance, the SGA seems to size itself appropriately.
SQL> sho sga
Total System Global Area 751595520 bytes
Fixed Size 2179536 bytes
Variable Size 415239728 bytes
Database Buffers 327155712 bytes
Redo Buffers 7020544 bytes
SQL>
Best Answer
Do not use
show sga
for querying the current SGA size.Total System Global Area
in the output ofshow sga
is computed asselect sum(value) from v$sga
, you can easily confirm this by enabling SQL trace.This includes
Variable Size
, and that is not the current usage. Usev$memory_dynamic_components
. For an even more detailed list, usev$sgastat
andv$pgastat
, I will not post output of those here.Now, decreasing
memory_target
(and that is not necessarily the SGA).show sga
still shows the old values.Notice how
SGA Target
did not change at all. Instead,PGA Target
was decreased. Decreasing it further:Notice how
Variable Size
has changed, butTotal System Global Area
has not.Variable Size
is there because,memory_max_size
andsga_max_size
was computed frommemory_target
at instance startup time.This allows us to increase SGA back to that point. But those you can not change dynamically: