ORACLE报错ORA-04030 koh-kghu sessi,pmucalm coll的分析处理步骤

近期有客户反馈某个数据查询进程频繁出现报错ORA-04030,让我们一起看看这个问题的排查过程:排错步骤

诊断并解决 ORA-4030 错误

ORA-4030 意味着什么?

该错误意味着 Oracle Server 进程无法从操作系统分配更多内存。该内存由 PGA(Program Global Area)组成,其内容取决于服务器配置。对于专用的服务器进程,内存包含堆栈以及用于保存用户会话数据、游标信息和排序区的 UGA(User Global Area)。在多线程配置中(共享服务器),UGA 被分配在 SGA(System Global Area)中,所以在这种配置下 UGA 不是造成 ORA-4030 错误的原因。

因此,ORA-4030 表示进程需要更多内存(堆栈 UGA 或 PGA)来执行其任务。

是什么导致了该错误?

由于发生了这个错误,您因此无法从操作系统分配内存。这个错误可能是进程本身导致的,例如进程需要过多的内存,或者一些其他原因导致操作系统内存被耗尽,例如 SGA 太大或系统虚拟内存(物理内存 + 交换空间)中要容纳的进程过多。许多操作系统会对单个进程能够获取的内存量加以限制,以便自我保护。所以我们就会有下列问题:

问题:

是否仍然有足够的可用内存?

是否设置了操作系统限制?

是否设置了 Oracle 限制?

哪个进程需要的内存过多?

如何收集有关进程实际正在执行的任务的信息?

如下是排查过程:

内存相关配置的排查:

复制代码
[root@ceshi ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            62G        8.6G        457M         23G         53G         29G
Swap:           14G        369M         14G
[root@ceshi ~]# su - oracle
Last login: Fri Apr 17 19:12:26 CST 2026 on pts/8
[oracle@ceshi ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256894
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[oracle@ceshi ~]$ cat /proc/meminfo 
MemTotal:       65789396 kB
MemFree:          434828 kB
MemAvailable:   31321392 kB
Buffers:               0 kB
Cached:         54853280 kB
SwapCached:         8780 kB
Active:         35263432 kB
Inactive:       27535868 kB
Active(anon):   19095076 kB
Inactive(anon): 13552020 kB
Active(file):   16168356 kB
Inactive(file): 13983848 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      15626236 kB
SwapFree:       15247868 kB
Dirty:               336 kB
Writeback:             0 kB
AnonPages:       7938264 kB
Mapped:         24407372 kB
Shmem:          24700592 kB
Slab:            1438644 kB
SReclaimable:    1266160 kB
SUnreclaim:       172484 kB
KernelStack:       17632 kB
PageTables:       516796 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    48520932 kB
Committed_AS:   87840524 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      153672 kB
VmallocChunk:   34359580672 kB
HardwareCorrupted:     0 kB
AnonHugePages:    356352 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      128848 kB
DirectMap2M:    66979840 kB

ulimit的分析:

复制代码
[oracle@ceshi ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256894
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

报错的后台TRACE的分析:分析4030报错相关的参数:ORA-04030: out of process memory when trying to allocate 169040 bytes (pga heap,kgh stack)

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Fri Apr 17 19:44:37 2026

Errors in file /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc (incident=41617):

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Incident details in: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc

Use ADRCI or Support Workbench to package the incident.

See Note 411.1 at My Oracle Support for error and packaging details.

Errors in file /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc (incident=41618):

ORA-04030: out of process memory when trying to allocate 169040 bytes (pga heap,kgh stack)

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Incident details in: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41618/TEST_ora_36010_i41618.trc

Use ADRCI or Support Workbench to package the incident.

See Note 411.1 at My Oracle Support for error and packaging details.

Fri Apr 17 19:44:39 2026

Dumping diagnostic data in directory=[cdmp_20260417194439], requested by (instance=1, osid=36010), summary=[incident=41618].

Errors in file /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc:

ORA-04030: out of process memory when trying to allocate 169040 bytes (pga heap,kgh stack)

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Errors in file /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc (incident=41619):

ORA-04030: out of process memory when trying to allocate 82456 bytes (pga heap,control file i/o buffer)

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Incident details in: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41619/TEST_ora_36010_i41619.trc

Use ADRCI or Support Workbench to package the incident.

See Note 411.1 at My Oracle Support for error and packaging details.

Errors in file /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc:

ORA-04030: out of process memory when trying to allocate 82456 bytes (pga heap,control file i/o buffer)

ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

查看最开始报错对应的TRACE文件:mmap(offset=239497216, len=8192) failed with errno=12,以及进程的内存使用情况75% 3113 MB, 199887 chunks: "pl/sql vc2 " PL/SQL ----

koh-kghu sessi ds=0x7f99e2e24ee8 dsprt=0x7f99e43755b8

25% 1023 MB, 65691 chunks: "pmucalm coll " PL/SQL -----

koh-kghu sessi ds=0x7f99e2e24ee8 dsprt=0x7f99e43755b8

这是内存达到了4GB限速,

复制代码
[oracle@ceshi ~]$ more /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc
Trace file /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name:    Linux
Node name:      ceshi
Release:        3.10.0-957.el7.x86_64
Version:        #1 SMP Thu Nov 8 23:39:32 UTC 2018
Machine:        x86_64
Instance name: TEST
Redo thread mounted by this instance: 1
Oracle process number: 94
Unix process pid: 36010, image: oracle@ceshi (TNS V1-V3)


*** 2026-04-17 19:44:37.066
*** SESSION ID:(2133.125) 2026-04-17 19:44:37.066
*** CLIENT ID:() 2026-04-17 19:44:37.066
*** SERVICE NAME:(SYS$USERS) 2026-04-17 19:44:37.066
*** MODULE NAME:(vagentd@ceshi (TNS V1-V3)) 2026-04-17 19:44:37.066
*** ACTION NAME:() 2026-04-17 19:44:37.066
 
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
Incident 41617 created, dump file: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc
ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Incident 41618 created, dump file: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41618/TEST_ora_36010_i41618.trc
ORA-04030: out of process memory when trying to allocate 169040 bytes (pga heap,kgh stack)
ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

Incident 41619 created, dump file: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41619/TEST_ora_36010_i41619.trc
ORA-04030: out of process memory when trying to allocate 82456 bytes (pga heap,control file i/o buffer)
ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)


*** 2026-04-17 19:45:06.684
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST
mmap(offset=239497216, len=8192) failed with errno=12 for the file oracleTEST

*** 2026-04-17 19:45:06.724
Incident 41620 created, dump file: /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41620/TEST_ora_36010_i41620.trc
ORA-04030: out of process memory when trying to allocate 1052696 bytes (kxs-heap-w,kllcqgf:kllsltba)


[oracle@ceshi ~]$ more /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc
Dump file /u01/app/oracle/diag/rdbms/TEST/TEST/incident/incdir_41617/TEST_ora_36010_i41617.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name:    Linux
Node name:      ceshi
Release:        3.10.0-957.el7.x86_64
Version:        #1 SMP Thu Nov 8 23:39:32 UTC 2018
Machine:        x86_64
Instance name: TEST
Redo thread mounted by this instance: 1
Oracle process number: 94
Unix process pid: 36010, image: oracle@ceshi (TNS V1-V3)


*** 2026-04-17 19:44:37.119
*** SESSION ID:(2133.125) 2026-04-17 19:44:37.119
*** CLIENT ID:() 2026-04-17 19:44:37.119
*** SERVICE NAME:(SYS$USERS) 2026-04-17 19:44:37.119
*** MODULE NAME:(vagentd@ceshi (TNS V1-V3)) 2026-04-17 19:44:37.119
*** ACTION NAME:() 2026-04-17 19:44:37.119
 
Dump continued from file: /u01/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_ora_36010.trc
ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu sessi,pmucalm coll)

========= Dump for incident 41617 (ORA 4030) ========
----- Beginning of Customized Incident Dump(s) -----
=======================================
TOP 10 MEMORY USES FOR THIS PROCESS
---------------------------------------
75% 3113 MB, 199887 chunks: "pl/sql vc2                "  PL/SQL   ----
         koh-kghu sessi  ds=0x7f99e2e24ee8  dsprt=0x7f99e43755b8
25% 1023 MB, 65691 chunks: "pmucalm coll              "  PL/SQL    -----
         koh-kghu sessi  ds=0x7f99e2e24ee8  dsprt=0x7f99e43755b8
 1%   23 MB, 1526 chunks: "free memory               "  
         session heap    ds=0x7f99e43755b8  dsprt=0xc0b8980
 0% 6461 KB,  26 chunks: "kllcqas:kllsltba          "  SQL
         QERHJ hash-joi  ds=0x7f99e38b5cf0  dsprt=0x7f99e4300c88
 0%  773 KB,   1 chunk : "kllcqc:kllcqslt           "  SQL
         QERHJ hash-joi  ds=0x7f99e38b5cf0  dsprt=0x7f99e4300c88
 0%  512 KB,   1 chunk : "HT buckets                "  SQL
         QERHJ hash-joi  ds=0x7f99e38b5cf0  dsprt=0x7f99e4300c88
 0%  348 KB,  86 chunks: "kxsFrame4kPage            "  
         session heap    ds=0x7f99e43755b8  dsprt=0xc0b8980

问题处理方法:

1、改大进程内存限制

root@ceshi \~\]# cat /proc/sys/vm/max_map_count 65530 --默认 \[root@ceshi \~\]# sysctl -p --改大 vm.max_map_count = 262144 \[root@ceshi \~\]# sysctl -a\|grep max_map vm.max_map_count = 262144 2、修改数据库隐含参数 SQL\> alter system set "_use_realfree_heap" = TRUE; SQL\> alter system set "_realfree_heap_pagesize_hint" = 262144 scope=spfile; 3、重启数据库验证,后续应用反馈可以正常使用。(根本的解决办法是优化业务逻辑和SQL,避免大量的PGA内存使用)

相关推荐
Polar__Star2 小时前
php怎么调用OPPO AI图像超分_php如何将低分辨率图放大不失真
jvm·数据库·python
m0_678485452 小时前
CSS如何让文字超出两行显示省略号_使用line-clamp属性限制
jvm·数据库·python
gmaajt2 小时前
SQL如何统计每个类别的订单总额_使用SUM与GROUP BY聚合分析
jvm·数据库·python
山河梧念2 小时前
【保姆级教程】VMware虚拟机安装全流程
android·java·数据库
志栋智能2 小时前
运维超自动化的本质:效率、质量与创新的三重奏
运维·服务器·数据库·安全·自动化
2301_803875612 小时前
如何高效实现多用户通知系统而不造成数据库冗余
jvm·数据库·python
Chasing__Dreams2 小时前
Redis--基础知识点--29--HyperLogLog
数据库·redis·缓存
weixin_580614002 小时前
SQL如何统计分组内的最高和最低值_MAX与MIN聚合应用
jvm·数据库·python
baidu_340998822 小时前
JavaScript中函数调用的四种模式及其this绑定优先级表
jvm·数据库·python