Windows – ORA-04031: unable to allocate bytes of shared memory (“”,“”,“”,“”)

memoryoraclewindows

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

Best Answer

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.