HiveBrain v1.2.0
Get Started
← Back to all entries
debugMinor

ORA-04031: unable to allocate bytes of shared memory ("","","","")

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
shared04031unableoraallocatebytesmemory

Problem

I am receiving this error in a development database.
It happens on some specific queries (simple inserts and deletes via .NET application).
The database is used by one user, and error happens regardless for how long the database was running.

The only memory related parameter which is set is: MEMORY_TARGET=1.2G

Oracle 11.2 x64 Standard Edition One
Windows Server 2008 R2

Solution

Your application is probably not using bind variables, which has caused the SGA to become fragmented (it fills up with multiple copies of SQL that use literals instead of binds).

You can temporarily fix the problem by flushing the shared pool with:

alter system flush shared_pool;


There's a workaround you can try to stop it happening in the future.

Turn on cursor sharing, then bounce the database:

ALTER SYSTEM SET cursor_sharing='SIMILAR' SCOPE=BOTH;


The only real way of fixing this is to rewrite your application so that it uses bind variables.

Code Snippets

alter system flush shared_pool;
ALTER SYSTEM SET cursor_sharing='SIMILAR' SCOPE=BOTH;

Context

StackExchange Database Administrators Q#12008, answer score: 8

Revisions (0)

No revisions yet.