ORA-04036: PGA Memory Exceeds PGA_AGGREGATE_LIMIT
ORA-04036 means the combined private PGA memory used in an Oracle instance or pluggable database has exceeded its configured PGA_AGGREGATE_LIMIT, so Oracle has interrupted work to bring memory use down. The reliable fix is to identify the affected scope and active PGA consumers, reduce the workload’s memory demand, or raise the hard limit only after confirming the host has sufficient capacity. Oracle may interrupt the largest PGA-consuming sessions, but an allocation from private memory used by more than one Oracle process can instead interrupt the allocating process, according to Oracle’s ORA-04036 error documentation.
Use this table to match the error pattern to the safest first action.
| Symptom | Likely Cause | First Action |
|---|---|---|
A job ends with ORA-00028 and ORA-04036 |
Aggregate PGA crossed the hard limit; Oracle killed sessions to recover memory | Identify all large PGA consumers and the SQL or jobs they were running |
| Error says “instance or PDB” | The breached limit may be at instance scope or PDB scope | Confirm the current container before changing a parameter |
| A parallel query, ETL job, large sort, hash join, or bulk PL/SQL run triggers the error | One workload or several concurrent workloads require too much private memory | Reduce concurrency, parallelism, batch size, or memory-heavy processing |
Diagnostics identify MGA or DGA |
Memory shared by more than one Oracle process triggered enforcement | Investigate the interrupted process, not only user sessions |
CREATE SEARCH INDEX fails for an Oracle Text index with stop patterns |
A known Oracle Text memory issue can occur during index creation | Plan a temporary or approved increase through ALTER SYSTEM |
What ORA-04036 Means
PGA, or Program Global Area, is private memory used by Oracle server and background processes. It supports work such as sorting, hash joins, bitmap processing, session state, PL/SQL collections, and other operations that cannot all be held in shared memory.
ORA-04036 is not merely a warning that a query used more memory than expected. It means private memory across the configured scope exceeded the PGA_AGGREGATE_LIMIT initialization parameter. Oracle then takes action to get back below that limit.
For ordinary PGA-limit enforcement, Oracle interrupts the largest sessions using PGA memory. That explains why an application may first report a disconnected or killed session, often alongside ORA-00028, and then show ORA-04036 in the job log or alert log.
The session that receives the error is not always the sole cause of the incident. Several moderately large sessions can collectively exceed the limit, especially when batch jobs, reporting queries, and parallel operations overlap.
PGA Memory, PGA Targets, and SGA Memory
Oracle manages several kinds of memory, and the terms are easy to confuse.
- PGA is private memory associated with Oracle processes and sessions. Different sessions generally have different PGA allocations.
- SGA is shared memory used by the instance, including areas such as the buffer cache and shared pool.
PGA_AGGREGATE_TARGETdefines the PGA memory target Oracle uses for managing work areas.PGA_AGGREGATE_LIMITis the hard aggregate PGA ceiling that triggers ORA-04036 when exceeded.
A commonly used configuration sets PGA_AGGREGATE_LIMIT to 2 * PGA_AGGREGATE_TARGET, but the values configured in the affected instance or PDB are what matter. Do not assume that a relationship is appropriate for a particular host without considering SGA size, operating-system memory, other Oracle processes, and other applications on the server.
In SQL*Plus or SQLcl, inspect the configured hard limit with:
SHOW PARAMETER pga_aggregate_limit
Inspect the PGA target with:
SHOW PARAMETER pga_aggregate_target
A high PGA_AGGREGATE_TARGET does not guarantee that an individual workload is safe. A single poorly shaped query, excessive parallelism, or several overlapping memory-intensive jobs can still drive total private memory to the hard limit.
How to Fix ORA-04036 Safely
Safely fix ORA-04036 by identifying its scope and PGA consumers, reducing peak workload demand, and recording current parameter values before changes.
Step 1: Identify Whether the Limit Is at Instance or PDB Scope
Start by determining where the error occurred. In a multitenant database, ORA-04036 can apply to the entire instance or to a specific PDB. Changing a setting in the wrong container can leave the real limit unchanged.
- Connect to the same database service used by the failing application or job.
- In SQL*Plus or SQLcl, display the current container:
SHOW CON_NAME
- Record the exact ORA-04036 message, timestamp, application module, job name, and any companion errors such as
ORA-00028. - Record the current values of both PGA parameters before making any change.
If you use a graphical client rather than SQL*Plus or SQLcl, query the parameters directly:
SELECT name, value
FROM v$parameter
WHERE name IN ('pga_aggregate_limit', 'pga_aggregate_target')
ORDER BY name;
I use a database client for these read-only checks first, because it separates diagnosis from an application retry that could immediately recreate the memory spike.
Step 2: Find the PGA Consumers Active at the Time
Check both aggregate PGA statistics and the sessions currently holding the most PGA. You may need a DBA account or privileges to read dynamic performance views.
This query shows useful instance-level PGA statistics:
SELECT name, value, unit
FROM v$pgastat
WHERE name IN (
'aggregate PGA target parameter',
'aggregate PGA auto target',
'total PGA allocated',
'total PGA inuse',
'maximum PGA allocated',
'over allocation count'
)
ORDER BY name;
Then list user sessions by allocated PGA memory:
SELECT s.sid,
s.serial#,
s.username,
s.status,
s.module,
p.spid,
ROUND(p.pga_used_mem / 1024 / 1024, 1) AS pga_used_mb,
ROUND(p.pga_alloc_mem / 1024 / 1024, 1) AS pga_alloc_mb,
ROUND(p.pga_freeable_mem / 1024 / 1024, 1) AS pga_freeable_mb
FROM v$session s
JOIN v$process p
ON p.addr = s.paddr
WHERE s.type = 'USER'
ORDER BY p.pga_alloc_mem DESC;
Treat this as a current snapshot, not proof of what happened earlier. A session Oracle already killed will no longer appear, and a failed batch job may have released most of its memory before you investigate.
Look for patterns rather than one automatically guilty session:
- The same module, scheduler job, or service appears across several large sessions.
- A report or ETL process starts at the same time as the failures.
- A parallel SQL operation creates multiple high-memory worker sessions.
- A PL/SQL process loads an unbounded collection or handles a very large batch in memory.
- A query plan uses large sort or hash operations because of missing filters, poor join order, stale statistics, or unexpected row counts.
The best repair lowers the workload’s peak private-memory demand before increasing the database-wide memory ceiling.
Step 3: Reduce the Workload’s PGA Demand
Choose the smallest change that removes the memory spike while preserving the job’s result.
- Stop overlapping heavy jobs where possible. Running a reporting query, index build, data load, and reconciliation batch at the same time can push aggregate PGA over the limit even when each workload succeeds alone.
- Reduce SQL parallelism for the failing statement, job, or service. Parallel execution can multiply PGA demand because each worker may need its own sort, hash, or work area.
- Process large application batches in smaller units. This is especially important for bulk PL/SQL code that stores rows in collections before writing them.
- Tune the failing SQL. Inspect its execution plan, expected versus actual row counts, join methods, sort operations, and predicates. A query returning or joining far more rows than intended can consume PGA quickly.
- Re-run one controlled test of the changed workload while monitoring PGA statistics and the largest active sessions.
Do not kill unrelated sessions simply because they appear high in the snapshot. First establish whether they are part of the same workload and whether their memory allocation is still growing.
Step 4: Increase PGA_AGGREGATE_LIMIT Only After Capacity Review
Oracle’s direct action for ORA-04036 is to increase PGA_AGGREGATE_LIMIT or reduce memory usage. Raising the limit can be appropriate for a legitimate, predictable workload, but it transfers pressure from Oracle’s guardrail to the operating system.
Before increasing it, confirm that the server has capacity for the higher private-memory ceiling in addition to:
- the SGA;
- Oracle background processes;
- the operating system;
- monitoring, backup, security, and cluster software;
- other databases or applications on the same host.
Use an approved value based on measured peak usage and host capacity, not a value copied from another database. If the affected scope is a PDB, make the change in the correct PDB context; if the limit is at instance scope, use the instance’s approved change process.
The following is a statement pattern, not a value to copy unchanged. Replace <approved_limit> with the reviewed limit and its unit:
ALTER SYSTEM SET pga_aggregate_limit = <approved_limit> SCOPE=BOTH;
Keep the previous value in the change record so you can roll back if the host begins swapping, memory pressure alerts appear, or other workloads become unstable.
Avoid treating removal of the hard limit as a routine production fix. The limit exists to prevent aggregate private memory from exhausting the host and turning one failed job into an instance-wide availability problem.
Step 5: Validate the Fix Under Controlled Load
A configuration change or SQL change is complete only after the original workload succeeds under realistic conditions.
- Run the formerly failing job during a controlled period, preferably without unrelated batch workloads.
- Watch
v$pgastatand the largest PGA sessions while it runs. - Confirm the application completes without
ORA-04036,ORA-00028, or unexpected disconnects. - Check the alert log for repeated PGA-limit messages.
- Re-test during the normal concurrency window if the original failure happened only when several jobs overlapped.
If the error returns only under concurrency, the root cause is aggregate demand. Lowering one query’s memory use may help, but scheduling and parallelism controls may still be necessary.
Special ORA-04036 Cases
ORA-04036 can affect an instance or PDB, interrupt MGA or DGA allocation processes, or occur during Oracle Text search index creation.
PDB-Level PGA Limit Breaches
An ORA-04036 message can identify either an instance or a PDB. A PDB can exceed its applicable PGA limit even when another PDB appears quiet or the host has free memory.
Confirm the connection container and the parameter values in that scope before changing anything. Do not assume an instance-level change fixes a PDB-level breach, and do not assume a PDB setting addresses an instance-wide overload.
MGA and DGA Process Interruptions
Oracle does not always resolve ORA-04036 by choosing a single high-PGA user session. If the breached allocation involves private memory used by more than one Oracle process, identified as MGA or DGA, Oracle interrupts the allocating process.
In this case, correlate the interruption with the process type, job, feature, and timestamp in Oracle diagnostics. A standard “top user sessions by PGA” query is still useful context, but it may not identify the direct victim or the true allocation path.
Oracle Text Search Index Creation
Oracle Database 12c Release 2 has a documented Oracle Text case in which indexes using stoplists with stop patterns can consume enough PGA to fail during CREATE SEARCH INDEX. The supported workaround is to increase PGA_AGGREGATE_LIMIT through ALTER SYSTEM so the index creation can complete, as described in Oracle’s Oracle Text known-bugs documentation.
Treat this as a planned maintenance operation:
- Confirm that the failing statement is creating an Oracle Text search index and uses stoplists with stop patterns.
- Capture the existing PGA setting and verify host capacity.
- Apply the approved increased limit through
ALTER SYSTEM. - Run the index creation while monitoring PGA use and alert logs.
- Restore the planned configuration if the increased capacity was only required for the index build, then verify the completed index and application searches.
How to Prevent Future PGA Limit Errors
Prevent future ORA-04036 errors by baselining normal and peak PGA use, controlling concurrent memory-heavy work, and retaining an incident record.
Baseline Normal and Peak PGA Use
Collect PGA statistics during ordinary workload periods and during scheduled peaks. The useful comparison is not just current PGA allocation, but the relationship between normal demand, peak demand, concurrent jobs, and the configured hard limit.
Track recurring high-memory modules, reports, batch jobs, and application releases. A memory spike that starts after a deployment often points to changed SQL shape, higher data volume, different bind values, or newly enabled parallelism.
Control Concurrent Memory-Heavy Work
Schedule large sorts, index builds, ETL jobs, analytics, and reporting workloads so they do not all peak together. When a workload requires parallelism, account for the aggregate memory used by all workers, not only the coordinator session.
For application code, avoid keeping unbounded result sets or large arrays in memory. Stream results when possible, batch large writes, and release application-side resources promptly.
Keep a Repeatable Incident Record
For every ORA-04036 event, retain:
- the exact error text and timestamp;
- whether the scope was an instance or PDB;
- the values of
PGA_AGGREGATE_TARGETandPGA_AGGREGATE_LIMIT; - top PGA sessions and modules;
- SQL IDs, job names, and execution plans where available;
- the workload overlap present at the time;
- the change that resolved the issue.
That record makes the next incident faster to diagnose and helps distinguish a capacity problem from a query or scheduling regression.
Frequently Asked Questions
What Is PGA Memory in Oracle Database?
PGA is private memory used by Oracle server and background processes for session-specific work such as sorts, hash joins, PL/SQL memory, and process state. Unlike SGA memory, PGA is generally not a shared pool available to every session. Aggregate PGA use across the applicable instance or PDB is what ORA-04036 monitors.
What Are PGA_AGGREGATE_TARGET and PGA_AGGREGATE_LIMIT?
PGA_AGGREGATE_TARGET is Oracle’s target for PGA memory management, while PGA_AGGREGATE_LIMIT is the hard ceiling that can trigger ORA-04036. A common configuration uses PGA_AGGREGATE_LIMIT at 2 * PGA_AGGREGATE_TARGET, but the correct setting depends on the actual database scope and available host memory. Check both values in the affected instance or PDB before changing either one.
What Is the Difference Between SGA and PGA in Oracle?
SGA is shared instance memory used for components such as cached data blocks and shared SQL structures. PGA is private process memory used for work performed by individual sessions or Oracle processes. ORA-04036 concerns aggregate PGA use, although an SGA that is too large can leave insufficient operating-system memory for PGA growth.
Why Did Oracle Kill My Session Instead of the Query That Caused the Problem?
Oracle normally interrupts the largest sessions using PGA memory to bring aggregate private memory below PGA_AGGREGATE_LIMIT. The killed session may be a major consumer, but another workload or several concurrent sessions may have created the overall pressure. If MGA or DGA memory is involved, Oracle can interrupt the allocating process instead of selecting a user session.
Can ORA-04036 Apply to a PDB or Autonomous Transaction Processing?
ORA-04036 can apply to a PDB as well as an instance, so first confirm whether the error identifies PDB or instance scope. Capture the exact error, timestamp, SQL or job details, and PGA symptoms to identify the affected scope and workload.
