Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

ORA-04031: unable to allocate nn bytes of shared memory

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 08 Nov, 2021
  • 0 Comments
  • 1 Min Read

ORA-04031: unable to allocate nn bytes of shared memory

ORA-04031: unable to allocate nn bytes of shared memory

Question: I am getting the error ORA-04031 Cannot allocate shared memory. I've tried increasing my init.ora shared_pool_size, but to no avail. What are some causes for the ORA-04031 error, and how do I fix it?

Answer: The ORA-04031 error has many root causes. Also, see MOSC notes 146599.1 and 396940.1 for more details for resolving the ORA-04031 error:

1.Heavy fragmentation of the shared pool - This can be fixed by increasing the shared_pool_size or doing a "alter system flush shared pool" or bouncing the instance.

2.Too many pinned packages - If you have pinned lots of packages with dbms_shared_pool.keep, they have not leave enough room for new work.

Ultimately the solution to a ORA-04031 error is adding RAM to shared_pool_size and/or shared_pool_reserved_size. In 11g and beyond , if using AMM, increase memory_max_size to resolve the ORA-04031 error.

The Oracle documentation has these notes on the ORA-04031 error:

ORA-04031: unable to allocate nn bytes of shared memory

Cause: More shared memory is needed than was allocated in the shared pool

Action: If the shared pool is out of memory, either use the dbms_shared_pool package to pin large packages, reduce your use of shared memory, or increase the amount of available shared memory by increasing the value of the INIT.ORA parameters "shared_pool_reserved_size" and "shared_pool_size". If the large pool is out of memory, increase the INIT.ORA parameter "large_pool_size".

The ORA-04031 error also happens when you are using automatic memory management (sga_max_size), and the memory specific is too small.