Академический Документы
Профессиональный Документы
Культура Документы
Purpose
~~~~~~~
DBAs are often alarmed by the perceived size of an Oracle process.
This note describes the various aspects of measuring the actual size.
INTRODUCTION
The two main reason for incorrect reporting of process memory usage are:
inclusion of non-private (i.e. shared) memory in the process memory figure,
and the operating system not reclaiming freed memory. These topics are
covered in more detail below.
N.B. The SGA and TEXT regions are shared by all Oracle processes. These are
mapped only once into memory, and not once per process. As such, these are not
part of the incremental cost of spawning a new Oracle process.
Unfortunately, commands such as 'ps' and 'top' include TEXT sizes when
measuring private data. Further, the SGA size can also be included, giving a
wildly inaccurate figure for the private data of a server process.
Some operating systems provide better tools for measuring process sizes. For
example, Solaris has /usr/proc/bin/pmap, and HP has glance (view the process'
virtual memory map) or the kernel debugger q4.
Here is an example of using 'ps', 'top' and 'pmap' on Solaris, against an
Oracle server process (pid 3254):
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=qmqe8t2fh_989&id=174555.1 1/5
1/20/2015 Document 174555.1
% top
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
3254 usupport 1 59 0 148M 124M sleep 0:00 0.05% oracle
% /usr/proc/bin/pmap -x 3254
3254: oracleV817 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
Address Kbytes Resident Shared Private Permissions Mapped File
00010000 26744 9368 8416 952 read/exec oracle <--TEXT
01A3C000 272 272 208 64 read/write/exec oracle <--TEXT
01A80000 152 144 - 144 read/write/exec [ heap ] <--private DATA
80000000 114928 114928 - 114928 read/write/exec/shared [shmid=0x191] <--SGA
...<deleted some output here>....
-------- ------ ------ ------ ------
total Kb 148024 127424 10896 116528
This highlights that the private data area of approx 150kB cannot be measured
accurately from standard operating system utilities such as 'ps' and 'top'
whereas 'pmap' allows a more accurate figure to be determined.
The amount of memory that Oracle currently has, and has ever had in these heaps
is obtained from the following statistics:
STATISTIC# NAME
---------- ------------------
25 session pga memory
26 session pga memory max
A large PGA/UGA does not necessarily indicate a problem. For example, the
following init.ora parameters affect the size:
Parameter:SORT_AREA_SIZE
Parameter:SORT_AREA_RETAINED_SIZE
Parameter:HASH_AREA_SIZE
An alternate method to check the high level breakdown of all pga processs will be:
IS THERE A PROBLEM?
===================
Firstly, standard operating system utilities such as 'ps' and 'top' should not
be used to get absolute figures, but used instead to observe trends (for
example, is a process size increasing or decreasing), for the reasons
previously stated. A specialist utility such as 'pmap' should be used to get a
more accurate figure. Even this may be misleading, as the operating system may
not have reclaimed previously freed memory.
Always query the database, using a query similar to the v$sesstat SQL given
above, to determine how much memory Oracle thinks it is using.
If such a query shows a session's memory usage constantly increasing over time,
without leveling off, then there may be a leak of some description. For example,
a process may be allocating memory for a particular repeated operation, but not
freeing it in between. A leak would typically result in a large process size
that cannot be explained by the related init.ora parameter settings.
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=qmqe8t2fh_989&id=174555.1 3/5
1/20/2015 Document 174555.1
If a process size keeps growing, then it may eventually fail with an ORA-4030
"out of process memory when trying to allocate %s bytes" error if the operating
system is exhausted of memory, or the memory size hits some operating system
defined limit (such as maxdsiz on HP-UX).
To start diagnosing a problem with the process size, such as a suspected leak,
a heapdump of the offending process is required:
$ svrmgrl or sqlplus
SQL> connect internal (or '/ as sysdba')
SQL> oradebug setospid <pid>
SQL> oradebug unlimit
SQL> oradebug dump heapdump 5 <--this dumps PGA and UGA heaps
These should be run periodically, from near the start of the session, and
must show the increase in memory.
3. Once the memory usage starts to increase, get multiple heapdumps (say a
maximum of five), separated by a time period that will highlight the
increase. Note that all heapdumps will write to the same trace file in
the user_dump_dest (for non-background processes). This will potentially
lead to a large trace file, so be aware of this when deciding when to dump
the heaps, and how often.
Related Documents
~~~~~~~~~~~~~~~~~
Search Words:
~~~~~~~~~~~~~
ORA-04030
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=qmqe8t2fh_989&id=174555.1 4/5
1/20/2015 Document 174555.1
REFERENCES
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=qmqe8t2fh_989&id=174555.1 5/5