Heap dumps show details about the memory allocation and distribution in the shared pool and library cache including the details about the objects. It will also show the details about the cursors and the latch information when level 2 is used. It will have the details about the memory chunks (free, freeable, permanent, and recreatable) and their sizes. It will also have the information about the hash buckets and freelists inside the shared pool. Heap dumps are often requested by Oracle Support to diagnose shared pool related errors.
Following methods show how to produce a heap dump.
The first ALTER SESSION below will immediately produce a heap dump at supplied level number, while the second ALTER SESSION command will produce the heap dump when the session encounters ORA-4031 error.
alter session set events 'immediate trace name heapdump level <level>';
alter session set events '4031 trace name heapdump level 2';
The following oradebug command sequence shows how to produce an immediate heap dump at level 10.
oradebug setmypid
oradebug unlimit
oradebug dump heapdump < level >
The decimal value of shown in the following table can be used as level to control the dump information written to the trace file.
Heap | Hex | Dec |
---|---|---|
PGA | 0x01 | 1 |
SGA | 0x02 | 2 |
UGA | 0x04 | 4 |
Current call | 0x08 | 8 |
User call | 0x10 | 6 |
Large pool | 0x20 | 32 |
The following snippet is from a trace file of the heap dump taken at level 2:
HEAP DUMP heap name="sga heap" desc=02E1DE80
extent sz=0x32c8 alt=104 het=32767 rec=9 flg=-126 opc=0
parent=00000000 owner=00000000 nex=00000000 xsz=0x0
******************************************************
HEAP DUMP heap name="sga heap(1,0)" desc=04766E28
extent sz=0xfc4 alt=104 het=32767 rec=9 flg=-126 opc=0
parent=00000000 owner=00000000 nex=00000000 xsz=0x400000
EXTENT 0 addr=14000000
Chunk 1400002c sz= 24 R-freeable "reserved stoppe"
Chunk 14000044 sz= 212900 R-free " "
Chunk 14033fe8 sz= 24 R-freeable "reserved stoppe"
Chunk 14034000 sz= 3959460 perm "perm " alo=3959460
Chunk 143faaa4 sz= 12172 perm "perm " alo=12172
Chunk 143fda30 sz= 7792 perm "perm " alo=7792
Chunk 143ff8a0 sz= 24 freeable "service names a"
Chunk 143ff8b8 sz= 32 recreate "fixed allocatio" latch=130F87AC