7.5 Resolving ORA-04031: unable to allocate bytes of shared memory Error Codes
For more information and videos, see https://blogs.oracle.com/database/post/ora-04031.
Follow these step-by-step instructions for everything you need to do to resolve ORA-04031
.
Understanding ORA-04031
The ORA-4031
error occurs because more shared memory was needed than was available.
The error message will show how much memory was unavailable, the memory pool encountering the error and details about the type of failed allocation.
Figure 7-16 ORA-04031 Internal Error Code: Arguments

If the error is raised by a database process, then an entry will be made in the database alert log, which will point to a trace file showing the process experiencing the problem.
Figure 7-17 Database Instance Alert Log

However, if the error is encountered by a user process, then nothing will be found in the alert log.
Irrespective of where the error occurs, the process encountering the problem is often the victim of the situation and typically not the cause.
The underlying cause could be one of varying different things such as:
- Initialization parameters for memory not being set high enough.
- Problems with auto tuning.
- Fragmentation in application design.
- Bug or memory leak.
ORA-04031 Error Troubleshooting Steps
The basic resolution steps for ORA-04031
are:
- Use AHF to generate and
ORA-04031
Service Request Data Collection (SRDC) - Use
ORA-04031
Troubleshooting Tool to find recommendations - Log a new SR using the diagnostic collection
Use AHF to generate an ORA-04031 Service Request Data Collection (SRDC)
In the first step, use AHF to generate an ORA-04031
diagnostic collection.
- Log into the machine where the
ORA-04031
occurred and as theOracle
user run the command:tfactl diagcollect –srdc ORA-04031
You’ll be prompted to enter the date and time of the
ORA-04031
you’re interested in, and then the database nameFor example:
$ tfactl diagcollect -srdc ora4031 Enter the time of the ORA-04031 [YYYY-MM-DD HH24:MI:SS,<RETURN>=ALL] : 2024-02-11 13:33:58 Enter the Database Name [Required for this SRDC] : CDB12 Components included in this collection: OS DATABASE CHMOS SOSREPORT Preparing to execute support diagnostic scripts. Executing DB Script srdc_db_ora4031.sql on CDB12 with timeout of 300 seconds... Collecting data for all nodes TFA is using system timezone for collection, All times shown in PST. Scanning files from 2023-10-27 13:03:58 PDT to 2023-10-27 14:03:58 PDT Collection Id : 20240212112211mymachine Detailed Logging at : /opt/oracle.ahf/data/repository/srdc_ora4031_collection_Mon_Feb_12_11_22_14_PST_2024_node_all/diagcollect_20240212112211_mymachine.log Waiting up to 120 seconds for collection to start 2024/02/12 11:22:20 PST : NOTE : Any file or directory name containing the string .com will be renamed to replace .com with dotcom 2024/02/12 11:22:20 PST : Collection Name : tfa_srdc_ora4031_Mon_Feb_12_11_22_13_PST_2024.zip 2024/02/12 11:22:20 PST : Collecting diagnostics from hosts : [mymachine2, mymachine] 2024/02/12 11:22:21 PST : Collecting Additional Diagnostic Information... 2024/02/12 11:22:21 PST : Scanning of files for Collection in progress... 2024/02/12 11:22:31 PST : Getting list of files satisfying time range [10/27/2023 13:03:58, 10/27/2023 14:03:58] 2024/02/12 11:22:36 PST : Executing DB Script runawr on cdb12 with timeout of 3600 seconds... 2024/02/12 11:22:42 PST : Executing TFA rdahcve with timeout of 600 seconds... 2024/02/12 11:22:51 PST : Collecting ADR incident files... 2024/02/12 11:24:20 PST : Executing IPS Incident Package Collection(s)... 2024/02/12 11:24:22 PST : Unexpected Error from ADR, please review the <hostname>_collection.log for details and consult Oracle Support if necessary 2024/02/12 11:24:22 PST : Executing SQL Script db_feature_usage.sql on cdb12 with timeout of 600 seconds... 2024/02/12 11:24:22 PST : Executing Collection for OS with timeout of 1800 seconds... 2024/02/12 11:24:29 PST : Executing Collection for SOSREPORT with timeout of 1860 seconds... 2024/02/12 11:25:29 PST : Completed Collection of Additional Diagnostic Information... 2024/02/12 11:25:32 PST : Completed Local Collection 2024/02/12 11:25:32 PST : Not Redacting this Collection on Exadata with no redaction option passed .. 2024/02/12 11:25:32 PST : Not Redacting this Collection ... 2024/02/12 11:25:32 PST : Remote Collection in Progress... 2024/02/12 11:26:13 PST : Collection completed on host: mymachine2 2024/02/12 11:26:13 PST : Collection completed on host: mymachine 2024/02/12 11:26:12 PST : Completed collection of zip files. .---------------------------------------. | Collection Summary | +-------------+-----------+------+------+ | Host | Status | Size | Time | +-------------+-----------+------+------+ | mymachine2 | Completed | 14MB | 182s | | mymachine | Completed | 27MB | 192s | '-------------+-----------+------+------' Logs are being collected to: /opt/oracle.ahf/data/repository/srdc_ora4031_collection_Mon_Feb_12_11_22_14_PST_2024_node_all /opt/oracle.ahf/data/repository/srdc_ora4031_collection_Mon_Feb_12_11_22_14_PST_2024_node_all/mymachine.tfa_srdc_ora4031_Mon_Feb_12_11_22_13_PST_2024.zip /opt/oracle.ahf/data/repository/srdc_ora4031_collection_Mon_Feb_12_11_22_14_PST_2024_node_all/mymachine2.tfa_srdc_ora4031_Mon_Feb_12_11_22_13_PST_2024.zip
Once it’s finished AHF will package everything for you in a zip file for each machine, as you progress you'll only need the one from the node where the problem occurred.
Now we can move on to step number two. Use the My Oracle Support ORA-04031 troubleshooting tool to find recommendations.
Use ORA-04031 Troubleshooting Tool to find recommendations
- Log into My Oracle Support and search for
ORA-04031
, or alternatively go to My Oracle Support ORA-04031 troubleshooting tool to access it directly. - When you get to the troubleshooting tool click the Next button at the top right.
Figure 7-18 My Oracle Support ORA-04031 Troubleshooting Tool
- Select the first radio button to choose to upload a TFA package.
- Click the Choose file button, select the zip from the failing node that AHF captured for you in step 1.
- Then press the Upload button.
Figure 7-19 Choose Upload
- Once this is uploaded click the Next button at the top right again.
Figure 7-20 Choose Upload
The troubleshooting tool will then analyze the contents of the diagnostic collection and compare the log entries against it’s list of known problems and recommend a solution.
Figure 7-21 Review Recommendations

If you go through the MOS troubleshooting tool and can’t find a solution, or you just need some more help, then you can easily log an SR with Oracle Support.
Log a new SR using the diagnostic collection
- Press the Create SR button at the bottom.
Figure 7-22 Create SR
- You’ll then be prompted to clarify your:
- Product
- Product Version
- Support Identifier
- Operating System
- SR severity
- Then press the Create SR button.
And, you’ll get a new SR number.
Figure 7-23 New SR
The AHF diagnostic collection you uploaded originally will be attached your SR and Oracle Support will take over.
Parent topic: Resolve Database Issues