MEMORY_MAX_TARGET - Set Maximum Memory for Oracle AMM
MEMORY_MAX_TARGET
Section titled “MEMORY_MAX_TARGET”Overview
Section titled “Overview”MEMORY_MAX_TARGET sets the absolute upper limit that MEMORY_TARGET can ever reach, either at startup or when adjusted dynamically at runtime. It acts as a ceiling for Oracle’s Automatic Memory Management (AMM) system, which controls the combined SGA and PGA automatically. If MEMORY_MAX_TARGET is 0 (the default), Oracle derives it from MEMORY_TARGET at instance startup and AMM is bounded by that initial value.
Setting MEMORY_MAX_TARGET higher than the initial MEMORY_TARGET gives the DBA the flexibility to grow MEMORY_TARGET later with a simple ALTER SYSTEM command — without bouncing the instance. This is the primary reason to set it explicitly.
Parameter Type: Static (requires instance restart to change)
Default Value: 0 (Oracle sets it equal to MEMORY_TARGET at startup)
Valid Range: 0 to OS-dependent maximum physical memory
Available Since: Oracle Database 11g Release 1 (11.1)
Modifiable: No — must be set in SPFILE and requires restart
PDB Modifiable: No — CDB-level only
Configuration
Section titled “Configuration”Viewing Current Value
Section titled “Viewing Current Value”-- Check both MEMORY_MAX_TARGET and MEMORY_TARGET in one querySELECT name, value, display_value, descriptionFROM v$parameterWHERE name IN ('memory_max_target', 'memory_target')ORDER BY name;
-- Check what is stored in SPFILE (persistent value)SELECT name, value, display_valueFROM v$spparameterWHERE name IN ('memory_max_target', 'memory_target');
-- Confirm AMM is active (MEMORY_TARGET > 0 means AMM is enabled)SELECT name, value / (1024 * 1024) AS value_mbFROM v$parameterWHERE name IN ('memory_target', 'memory_max_target', 'sga_target', 'pga_aggregate_target')ORDER BY name;Setting the Parameter
Section titled “Setting the Parameter”MEMORY_MAX_TARGET is static and can only be changed via SPFILE. You must restart the instance for the new value to take effect.
-- Set MEMORY_MAX_TARGET to 8 GB, leaving MEMORY_TARGET at its current value-- This reserves headroom to grow MEMORY_TARGET later without a restartALTER SYSTEM SET memory_max_target = 8G SCOPE = SPFILE;
-- Typical setup: set ceiling 25-50% above initial target-- e.g., MEMORY_TARGET = 6G, MEMORY_MAX_TARGET = 8GALTER SYSTEM SET memory_target = 6G SCOPE = SPFILE;ALTER SYSTEM SET memory_max_target = 8G SCOPE = SPFILE;
-- After restarting, you can grow MEMORY_TARGET dynamically up to 8GALTER SYSTEM SET memory_target = 7G; -- no restart neededALTER SYSTEM SET memory_target = 8G; -- still no restart needed (at ceiling)
-- Verify after restartSELECT name, display_value FROM v$parameterWHERE name IN ('memory_max_target', 'memory_target');Tuning Guidance
Section titled “Tuning Guidance”Recommended Values
Section titled “Recommended Values”| Environment | MEMORY_TARGET | MEMORY_MAX_TARGET | Notes |
|---|---|---|---|
| Small OLTP (< 8 GB RAM) | 2–4 GB | MEMORY_TARGET + 1 GB | Tight headroom on small servers |
| Medium OLTP (16–32 GB RAM) | 8–12 GB | MEMORY_TARGET + 25% | Comfortable growth room |
| Large OLTP (64+ GB RAM) | 20–40 GB | MEMORY_TARGET + 50% | Allow significant dynamic adjustment |
| Data Warehouse | 30–60 GB | MEMORY_TARGET + 25% | Large PGA requirements |
| RAC Node | Per-node SGA + PGA | Per-node ceiling | Set per instance |
How to Size
Section titled “How to Size”The key constraint on Linux is /dev/shm. Oracle AMM maps shared memory through the /dev/shm tmpfs filesystem. MEMORY_MAX_TARGET must not exceed the size of /dev/shm.
-- Step 1: Check current SGA and PGA consumption to establish a baselineSELECT 'SGA' AS component, sum(value) / (1024 * 1024) AS current_mbFROM v$sgaUNION ALLSELECT 'PGA Target', value / (1024 * 1024)FROM v$parameterWHERE name = 'pga_aggregate_target'UNION ALLSELECT 'PGA Actual', value / (1024 * 1024)FROM v$pgastatWHERE name = 'total PGA allocated';
-- Step 2: Check historical peak PGA usage to size PGA headroomSELECT value / (1024 * 1024) AS peak_pga_mbFROM v$pgastatWHERE name = 'maximum PGA allocated';
-- Step 3: Review AMM auto-tuned component sizes over timeSELECT component, current_size / (1024 * 1024) AS current_mb, min_size / (1024 * 1024) AS min_mb, max_size / (1024 * 1024) AS max_mb, user_specified_size / (1024 * 1024) AS user_specified_mb, last_oper_type, last_oper_modeFROM v$memory_dynamic_componentsORDER BY current_size DESC;# Check /dev/shm size on Linux — MEMORY_MAX_TARGET must not exceed thisdf -h /dev/shm
# If /dev/shm is too small, resize it in /etc/fstab:# tmpfs /dev/shm tmpfs defaults,size=12g 0 0# Then: mount -o remount /dev/shmMonitoring
Section titled “Monitoring”-- Monitor current AMM memory distributionSELECT component, current_size / (1024 * 1024) AS current_mb, max_size / (1024 * 1024) AS max_mbFROM v$memory_dynamic_componentsWHERE current_size > 0ORDER BY current_size DESC;
-- Check if MEMORY_TARGET is near the MEMORY_MAX_TARGET ceilingSELECT mt.value / (1024 * 1024) AS memory_target_mb, mmt.value / (1024 * 1024) AS memory_max_target_mb, ROUND(mt.value / mmt.value * 100, 1) AS pct_of_ceilingFROM v$parameter mt, v$parameter mmtWHERE mt.name = 'memory_target'AND mmt.name = 'memory_max_target';If pct_of_ceiling is above 90%, consider raising MEMORY_MAX_TARGET (requires restart) before the next planned maintenance window, then grow MEMORY_TARGET dynamically as needed.
Common Issues
Section titled “Common Issues”ORA-00845: MEMORY_TARGET not supported on this system
Section titled “ORA-00845: MEMORY_TARGET not supported on this system”This error occurs at startup when /dev/shm is smaller than MEMORY_TARGET (or MEMORY_MAX_TARGET). Oracle cannot allocate the required shared memory.
Resolution:
# Verify /dev/shm sizedf -h /dev/shm
# Option 1: Increase /dev/shm (persistent, recommended)# Edit /etc/fstab — change or add:# tmpfs /dev/shm tmpfs defaults,size=8g 0 0mount -o remount /dev/shm
# Option 2: Reduce MEMORY_MAX_TARGET to fit within /dev/shm# Connect with STARTUP NOMOUNT and edit spfile:# ALTER SYSTEM SET memory_max_target = 4G SCOPE = SPFILE;See the full ORA-00845 guide for step-by-step diagnosis.
MEMORY_MAX_TARGET cannot be set smaller than MEMORY_TARGET
Section titled “MEMORY_MAX_TARGET cannot be set smaller than MEMORY_TARGET”If you try to set MEMORY_MAX_TARGET below the current MEMORY_TARGET value, Oracle rejects the change.
-- Correct sequence: lower MEMORY_TARGET first, then MEMORY_MAX_TARGETALTER SYSTEM SET memory_target = 4G SCOPE = SPFILE;ALTER SYSTEM SET memory_max_target = 5G SCOPE = SPFILE;-- Restart required for both changes to take effect cleanlyAMM conflicts with hugepages on Linux
Section titled “AMM conflicts with hugepages on Linux”Linux hugepages (large pages) cannot be used when AMM (MEMORY_TARGET) is enabled because AMM requires /dev/shm memory-mapped files, which are incompatible with hugepages.
Resolution: Choose one approach:
- Use AMM: Disable hugepages. Set
MEMORY_TARGETandMEMORY_MAX_TARGET. Simpler management. - Use hugepages: Disable AMM (
MEMORY_TARGET = 0). UseSGA_TARGET+PGA_AGGREGATE_TARGETinstead. Better performance for large SGAs (> 8 GB).
-- Switch from AMM to ASMM (to use hugepages)ALTER SYSTEM SET memory_target = 0 SCOPE = SPFILE;ALTER SYSTEM SET memory_max_target = 0 SCOPE = SPFILE;ALTER SYSTEM SET sga_target = 8G SCOPE = SPFILE;ALTER SYSTEM SET pga_aggregate_target = 2G SCOPE = SPFILE;-- Restart requiredRelated Parameters
Section titled “Related Parameters”| Parameter | Relationship |
|---|---|
MEMORY_TARGET | The active AMM memory ceiling; cannot exceed MEMORY_MAX_TARGET |
SGA_TARGET | Used instead of AMM when MEMORY_TARGET = 0; ignored when AMM is active |
SGA_MAX_SIZE | Static SGA ceiling used with ASMM; irrelevant when AMM is active |
PGA_AGGREGATE_TARGET | PGA floor hint when AMM is active; ignored as a hard limit |
PGA_AGGREGATE_LIMIT | Hard PGA cap (12c+); applies regardless of AMM |
Related Errors
Section titled “Related Errors”- ORA-00845: MEMORY_TARGET not supported on this system
- ORA-04031: Unable to allocate shared memory
- ORA-27125: Unable to create shared memory segment
Version Notes
Section titled “Version Notes”| Version | Notes |
|---|---|
| 11.1 | MEMORY_TARGET and MEMORY_MAX_TARGET introduced with AMM |
| 11.2+ | Behavior unchanged; hugepages incompatibility documented |
| 12c+ | CDB/PDB architecture; both parameters are CDB-level only |
| 19c+ | AMM still supported; Oracle recommends ASMM + hugepages for large instances |
| 21c+ | No functional change; AMM remains available but ASMM is preferred at scale |