ORA-00845 MEMORY_TARGET Not Supported - Automatic Memory Management Guide
ORA-00845: MEMORY_TARGET Not Supported on This System
Section titled “ORA-00845: MEMORY_TARGET Not Supported on This System”Error Overview
Section titled “Error Overview”Error Text: ORA-00845: MEMORY_TARGET not supported on this system
This critical startup error prevents Oracle database startup when Automatic Memory Management (AMM) cannot allocate the required memory. ORA-00845 typically occurs due to insufficient shared memory filesystem space or incompatible system configuration for AMM.
Understanding Automatic Memory Management
Section titled “Understanding Automatic Memory Management”AMM Architecture
Section titled “AMM Architecture”Automatic Memory Management (AMM)├── MEMORY_TARGET (Total memory pool)├── MEMORY_MAX_TARGET (Maximum memory)├── System Global Area (SGA)│ ├── Buffer Cache│ ├── Shared Pool│ ├── Large Pool│ └── Java Pool└── Program Global Area (PGA) ├── Sort Area ├── Hash Area └── Cursor Cache
Memory Allocation Flow
Section titled “Memory Allocation Flow”- MEMORY_TARGET set → Oracle allocates shared memory
- Shared memory filesystem (/dev/shm) must have sufficient space
- Dynamic allocation between SGA and PGA components
- Operating system must support required memory operations
Common Causes
Section titled “Common Causes”1. Insufficient /dev/shm Space
Section titled “1. Insufficient /dev/shm Space”- /dev/shm filesystem smaller than MEMORY_TARGET
- Other processes consuming shared memory space
- Incorrect /dev/shm mount configuration
- Container environments with limited shared memory
2. Operating System Limitations
Section titled “2. Operating System Limitations”- Older Linux kernels lacking AMM support
- Missing hugepages configuration
- Incompatible shared memory implementation
- SELinux restrictions blocking memory allocation
3. Configuration Mismatches
Section titled “3. Configuration Mismatches”- MEMORY_TARGET exceeds available system memory
- MEMORY_MAX_TARGET set too high
- Conflicting manual memory parameter settings
- Instance already running with different memory configuration
4. Environment-Specific Issues
Section titled “4. Environment-Specific Issues”- Docker containers without proper shared memory setup
- Cloud instances with restricted memory access
- Virtual machines with insufficient memory allocation
- Container orchestration platforms with memory limits
Diagnostic Steps
Section titled “Diagnostic Steps”1. Check Current Memory Configuration
Section titled “1. Check Current Memory Configuration”-- Check memory parameters (if database can connect)SHOW PARAMETER memory;SHOW PARAMETER sga;SHOW PARAMETER pga;
-- Check from SPFILE if database won't startstrings $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora | grep -i memory
2. Verify System Memory and /dev/shm
Section titled “2. Verify System Memory and /dev/shm”# Check total system memoryfree -hcat /proc/meminfo | grep MemTotal
# Check /dev/shm filesystemdf -h /dev/shmmount | grep shm
# Check /dev/shm mount optionscat /proc/mounts | grep shm
# Check available space vs Oracle requirementsls -la /dev/shm/du -sh /dev/shm/*
3. Analyze Memory Requirements
Section titled “3. Analyze Memory Requirements”# Calculate memory requirements from SPFILEORACLE_SID=ORCL # Set your SIDSPFILE=$ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
echo "Current SPFILE memory settings:"strings $SPFILE | grep -i memory_targetstrings $SPFILE | grep -i memory_max_targetstrings $SPFILE | grep -i sga_target
# Check for Oracle shared memory segmentsipcs -m | grep oracleipcs -m | grep $ORACLE_USER
4. Check Alert Log and Trace Files
Section titled “4. Check Alert Log and Trace Files”# Check alert log for detailed error informationtail -n 50 $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_$ORACLE_SID.log
# Look for patterns like:# - "Starting ORACLE instance"# - "MEMORY_TARGET not supported"# - "Automatic Memory Management is disabled"# - "ORA-00845"
# Check for related trace filesls -la $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/ | grep -E "(ora_|ORA_)" | tail -10
Immediate Solutions
Section titled “Immediate Solutions”Solution 1: Increase /dev/shm Size
Section titled “Solution 1: Increase /dev/shm Size”Temporary /dev/shm Resize
Section titled “Temporary /dev/shm Resize”# Check current /dev/shm sizedf -h /dev/shm
# Calculate required size (MEMORY_TARGET + 20% overhead)# Example: For MEMORY_TARGET=8G, need at least 10G /dev/shm
# Resize /dev/shm temporarily (requires root)sudo mount -o remount,size=12G /dev/shm
# Verify new sizedf -h /dev/shm
# Attempt Oracle startupsqlplus / as sysdbaSTARTUP;
Permanent /dev/shm Configuration
Section titled “Permanent /dev/shm Configuration”# Backup current fstabsudo cp /etc/fstab /etc/fstab.backup
# Edit /etc/fstab (requires root)sudo vi /etc/fstab
# Add or modify the /dev/shm entry:tmpfs /dev/shm tmpfs defaults,size=12G 0 0
# Alternative with more explicit options:tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec,size=12G 0 0
# Test the configurationsudo mount -o remount /dev/shmdf -h /dev/shm
# Restart Oraclesqlplus / as sysdbaSTARTUP;
Solution 2: Disable Automatic Memory Management
Section titled “Solution 2: Disable Automatic Memory Management”Switch to Manual Memory Management
Section titled “Switch to Manual Memory Management”-- Connect using PFILE or SPFILE modificationsqlplus / as sysdba
-- Create PFILE from SPFILE for modificationCREATE PFILE='/tmp/init$ORACLE_SID.ora' FROM SPFILE;
-- Exit and edit PFILEEXIT;
# Edit the PFILE to disable AMMvi /tmp/init$ORACLE_SID.ora
# Comment out or remove these lines:# *.memory_target=8G# *.memory_max_target=8G
# Add manual memory settings instead:*.sga_target=6G*.pga_aggregate_target=2G
# Alternative: Set individual SGA components# *.sga_target=0# *.shared_pool_size=1G# *.db_cache_size=4G# *.large_pool_size=500M# *.java_pool_size=200M# *.pga_aggregate_target=2G
-- Start with PFILEsqlplus / as sysdbaSTARTUP PFILE='/tmp/init$ORACLE_SID.ora';
-- Create new SPFILE with corrected parametersCREATE SPFILE FROM PFILE='/tmp/init$ORACLE_SID.ora';
-- Restart with new SPFILESHUTDOWN IMMEDIATE;STARTUP;
-- Verify memory configurationSHOW PARAMETER memory;SHOW PARAMETER sga;SHOW PARAMETER pga;
Solution 3: Reduce Memory Allocation
Section titled “Solution 3: Reduce Memory Allocation”Lower MEMORY_TARGET Values
Section titled “Lower MEMORY_TARGET Values”-- If database starts intermittently, reduce memory allocationsqlplus / as sysdba
-- Reduce memory targetsALTER SYSTEM SET memory_target = 6G SCOPE = SPFILE;ALTER SYSTEM SET memory_max_target = 6G SCOPE = SPFILE;
-- Restart databaseSHUTDOWN IMMEDIATE;STARTUP;
Calculate Optimal Memory Settings
Section titled “Calculate Optimal Memory Settings”#!/bin/bash# memory_calculator.sh - Calculate optimal Oracle memory settings
# Get system memory in GBTOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024))
echo "System Memory Analysis:"echo "Total System Memory: ${TOTAL_MEM_GB}GB"
# Calculate recommendationsOS_RESERVE_GB=2OTHER_APPS_GB=1AVAILABLE_GB=$((TOTAL_MEM_GB - OS_RESERVE_GB - OTHER_APPS_GB))
# Oracle memory recommendations (70% of available)ORACLE_MEM_GB=$((AVAILABLE_GB * 70 / 100))SGA_GB=$((ORACLE_MEM_GB * 75 / 100))PGA_GB=$((ORACLE_MEM_GB * 25 / 100))
echo ""echo "Recommended Oracle Memory Settings:"echo "MEMORY_TARGET: ${ORACLE_MEM_GB}G"echo "Or Manual Settings:"echo "SGA_TARGET: ${SGA_GB}G"echo "PGA_AGGREGATE_TARGET: ${PGA_GB}G"echo ""echo "Required /dev/shm size: $((ORACLE_MEM_GB + 1))G"
# Check current /dev/shmSHM_SIZE_KB=$(df /dev/shm | awk 'NR==2 {print $2}')SHM_SIZE_GB=$((SHM_SIZE_KB / 1024 / 1024))
echo "Current /dev/shm size: ${SHM_SIZE_GB}G"
if [ $SHM_SIZE_GB -lt $((ORACLE_MEM_GB + 1)) ]; then echo "WARNING: /dev/shm too small. Need to increase to $((ORACLE_MEM_GB + 1))G"else echo "OK: /dev/shm size is sufficient"fi
Long-Term Solutions
Section titled “Long-Term Solutions”1. Container Environment Configuration
Section titled “1. Container Environment Configuration”Docker Configuration
Section titled “Docker Configuration”# Dockerfile for Oracle with proper shared memoryFROM oracle/database:19.3.0-ee
# Configure shared memory in containerRUN echo "tmpfs /dev/shm tmpfs defaults,size=12G 0 0" >> /etc/fstab
# Set Oracle memory parametersENV ORACLE_MEMORY_TARGET=8GENV ORACLE_SGA_TARGET=6GENV ORACLE_PGA_TARGET=2G
# Run Oracle container with increased shared memorydocker run -d \ --name oracle-db \ --shm-size=12g \ -e ORACLE_SID=ORCL \ -e ORACLE_PDB=PDB1 \ -e ORACLE_PWD=YourPassword \ -e ORACLE_MEMORY_TARGET=8G \ -p 1521:1521 \ -p 5500:5500 \ oracle/database:19.3.0-ee
# Check container shared memorydocker exec oracle-db df -h /dev/shm
Kubernetes Configuration
Section titled “Kubernetes Configuration”apiVersion: apps/v1kind: Deploymentmetadata: name: oracle-databasespec: replicas: 1 selector: matchLabels: app: oracle-database template: metadata: labels: app: oracle-database spec: containers: - name: oracle image: oracle/database:19.3.0-ee env: - name: ORACLE_SID value: "ORCL" - name: ORACLE_PWD value: "YourPassword" - name: ORACLE_MEMORY_TARGET value: "8G" resources: requests: memory: "12Gi" cpu: "2" limits: memory: "16Gi" cpu: "4" volumeMounts: - name: dshm mountPath: /dev/shm - name: oracle-data mountPath: /opt/oracle/oradata volumes: - name: dshm emptyDir: medium: Memory sizeLimit: 12Gi - name: oracle-data persistentVolumeClaim: claimName: oracle-data-pvc
2. System Optimization for AMM
Section titled “2. System Optimization for AMM”Configure Hugepages for Better Performance
Section titled “Configure Hugepages for Better Performance”# Calculate hugepages neededMEMORY_TARGET_GB=8HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')HUGEPAGE_SIZE_MB=$((HUGEPAGE_SIZE_KB / 1024))HUGEPAGES_NEEDED=$((MEMORY_TARGET_GB * 1024 / HUGEPAGE_SIZE_MB))
echo "Hugepages calculation:"echo "Memory Target: ${MEMORY_TARGET_GB}GB"echo "Hugepage Size: ${HUGEPAGE_SIZE_MB}MB"echo "Hugepages Needed: ${HUGEPAGES_NEEDED}"
# Set hugepagessudo sysctl -w vm.nr_hugepages=$HUGEPAGES_NEEDED
# Make permanentecho "vm.nr_hugepages = $HUGEPAGES_NEEDED" | sudo tee -a /etc/sysctl.conf
# Configure Oracle to use hugepagessqlplus / as sysdbaALTER SYSTEM SET use_large_pages = TRUE SCOPE = SPFILE;
Memory Monitoring and Alerting
Section titled “Memory Monitoring and Alerting”-- Create memory monitoring procedureCREATE OR REPLACE PROCEDURE check_memory_config AS v_memory_target NUMBER; v_sga_size NUMBER; v_pga_size NUMBER; v_shm_available NUMBER;BEGIN -- Get current memory configuration SELECT value INTO v_memory_target FROM v$parameter WHERE name = 'memory_target';
SELECT SUM(value) INTO v_sga_size FROM v$sga;
SELECT value INTO v_pga_size FROM v$pgastat WHERE name = 'total PGA allocated';
-- Check if AMM is enabled IF v_memory_target > 0 THEN DBMS_OUTPUT.PUT_LINE('AMM enabled with MEMORY_TARGET: ' || ROUND(v_memory_target/1024/1024/1024, 2) || 'GB');
-- Check /dev/shm space (would need external script) DBMS_OUTPUT.PUT_LINE('Verify /dev/shm has sufficient space'); ELSE DBMS_OUTPUT.PUT_LINE('Manual memory management in use'); END IF;
DBMS_OUTPUT.PUT_LINE('Current SGA: ' || ROUND(v_sga_size/1024/1024/1024, 2) || 'GB'); DBMS_OUTPUT.PUT_LINE('Current PGA: ' || ROUND(v_pga_size/1024/1024/1024, 2) || 'GB');END;/
-- Run the checkEXEC check_memory_config;
3. Cloud Environment Best Practices
Section titled “3. Cloud Environment Best Practices”AWS RDS and EC2 Configuration
Section titled “AWS RDS and EC2 Configuration”# For AWS EC2 instances running Oracle# Choose memory-optimized instances (r5, r6i, x1e)
# Instance type recommendations:# r5.2xlarge: 64GB RAM - supports up to 40GB Oracle memory# r5.4xlarge: 128GB RAM - supports up to 80GB Oracle memory# r5.8xlarge: 256GB RAM - supports up to 180GB Oracle memory
# Configure /dev/shm in user data script#!/bin/bashecho "tmpfs /dev/shm tmpfs defaults,size=50G 0 0" >> /etc/fstabmount -o remount /dev/shm
# Set optimal kernel parametersecho "vm.nr_hugepages = 20480" >> /etc/sysctl.conf # 40GB hugepagessysctl -p
Azure and GCP Configuration
Section titled “Azure and GCP Configuration”# Azure VM configuration# Use memory-optimized series (Dv3, Ev3, Mv2)
# GCP configuration# Use memory-optimized machine types (n1-highmem, n2-highmem)
# Common cloud configuration script#!/bin/bash# cloud_oracle_setup.sh
# Get total memoryTOTAL_MEM_GB=$(free -g | awk 'NR==2{print $2}')ORACLE_MEM_GB=$((TOTAL_MEM_GB * 60 / 100)) # 60% for OracleSHM_SIZE_GB=$((ORACLE_MEM_GB + 5)) # Oracle memory + 5GB buffer
echo "Configuring Oracle for ${TOTAL_MEM_GB}GB system"echo "Oracle memory: ${ORACLE_MEM_GB}GB"echo "/dev/shm size: ${SHM_SIZE_GB}GB"
# Configure /dev/shmcp /etc/fstab /etc/fstab.backupecho "tmpfs /dev/shm tmpfs defaults,size=${SHM_SIZE_GB}G 0 0" >> /etc/fstabmount -o remount /dev/shm
# Configure hugepages if memory > 16GBif [ $ORACLE_MEM_GB -gt 16 ]; then HUGEPAGES=$((ORACLE_MEM_GB * 512)) # 2MB hugepages echo "vm.nr_hugepages = $HUGEPAGES" >> /etc/sysctl.conf sysctl -pfi
echo "Oracle memory configuration completed"
Prevention Strategies
Section titled “Prevention Strategies”1. Pre-deployment Validation
Section titled “1. Pre-deployment Validation”#!/bin/bash# validate_oracle_memory.sh - Pre-deployment memory validation
REQUIRED_MEMORY_GB=${1:-8}ORACLE_SID=${2:-ORCL}
echo "Validating memory configuration for Oracle $ORACLE_SID"echo "Required memory: ${REQUIRED_MEMORY_GB}GB"
# Check system memoryTOTAL_MEM_GB=$(free -g | awk 'NR==2{print $2}')if [ $TOTAL_MEM_GB -lt $((REQUIRED_MEMORY_GB * 2)) ]; then echo "ERROR: Insufficient system memory" echo "Required: $((REQUIRED_MEMORY_GB * 2))GB, Available: ${TOTAL_MEM_GB}GB" exit 1fi
# Check /dev/shmSHM_SIZE_GB=$(df /dev/shm | awk 'NR==2 {print int($2/1024/1024)}')if [ $SHM_SIZE_GB -lt $((REQUIRED_MEMORY_GB + 2)) ]; then echo "ERROR: Insufficient /dev/shm space" echo "Required: $((REQUIRED_MEMORY_GB + 2))GB, Available: ${SHM_SIZE_GB}GB" echo "Fix: sudo mount -o remount,size=$((REQUIRED_MEMORY_GB + 2))G /dev/shm" exit 1fi
# Check for existing Oracle processesif pgrep -f "ora_.*_$ORACLE_SID" > /dev/null; then echo "WARNING: Oracle instance $ORACLE_SID appears to be running"fi
echo "Memory validation completed successfully"
2. Automated Memory Management Scripts
Section titled “2. Automated Memory Management Scripts”#!/bin/bash# oracle_memory_manager.sh - Automated memory management
ORACLE_SID=${1:-ORCL}ACTION=${2:-check}
case $ACTION in "check") echo "Checking Oracle memory configuration..." df -h /dev/shm free -h ipcs -m | grep oracle ;;
"increase-shm") NEW_SIZE=${3:-16G} echo "Increasing /dev/shm to $NEW_SIZE..." sudo mount -o remount,size=$NEW_SIZE /dev/shm df -h /dev/shm ;;
"fix-amm") echo "Attempting to fix AMM configuration..."
# Check if database is running if pgrep -f "ora_smon_$ORACLE_SID" > /dev/null; then echo "Database is running, checking memory usage..." sqlplus -s / as sysdba << EOFSET PAGESIZE 0 FEEDBACK OFFSELECT 'Memory Target: ' || value/1024/1024/1024 || 'GB' FROM v\$parameter WHERE name='memory_target';SELECT 'SGA Size: ' || SUM(value)/1024/1024/1024 || 'GB' FROM v\$sga;EXIT;EOF else echo "Database is not running, checking /dev/shm..." df -h /dev/shm
# Attempt startup sqlplus / as sysdba << EOFSTARTUP;EXIT;EOF fi ;;
*) echo "Usage: $0 <ORACLE_SID> <check|increase-shm|fix-amm> [size]" exit 1 ;;esac
Related Errors
Section titled “Related Errors”- ORA-27125 - Unable to create shared memory segment
- ORA-04031 - Unable to allocate shared memory
- ORA-00600 - Internal error (memory corruption)
- ORA-01034 - Oracle not available (startup failure)
Emergency Response
Section titled “Emergency Response”Quick Recovery Steps
Section titled “Quick Recovery Steps”-
Check /dev/shm space immediately
Terminal window df -h /dev/shm -
Increase /dev/shm if needed
Terminal window sudo mount -o remount,size=16G /dev/shm -
Try database startup
sqlplus / as sysdbaSTARTUP; -
If still failing, disable AMM
CREATE PFILE='/tmp/init.ora' FROM SPFILE;-- Edit PFILE to remove memory_targetSTARTUP PFILE='/tmp/init.ora';
Quick Reference Commands
Section titled “Quick Reference Commands”# Check memory statusdf -h /dev/shmfree -hipcs -m | grep oracle
# Increase /dev/shmsudo mount -o remount,size=16G /dev/shm
# Oracle memory commandssqlplus / as sysdbaSHOW PARAMETER memory;ALTER SYSTEM SET memory_target = 6G SCOPE = SPFILE;STARTUP;
# Disable AMM emergencyCREATE PFILE FROM SPFILE;# Edit PFILE: comment out memory_target, add sga_target/pga_aggregate_targetSTARTUP PFILE='/path/to/pfile';
System Configuration Checklist
Section titled “System Configuration Checklist”# Essential /etc/fstab entrytmpfs /dev/shm tmpfs defaults,size=16G 0 0
# Essential /etc/sysctl.conf entries (for hugepages)vm.nr_hugepages = 8192vm.hugetlb_shm_group = 54321 # Oracle group ID
# Verify configurationmount -o remount /dev/shmsysctl -pdf -h /dev/shm