ORA-04031: unable to allocate string bytes of shared memory ("string","string","string","string")
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".
ORA-04031: unable to allocate 4096 bytes of shared memory ("shared pool","user","PL/SQL MPCODE","BAMIMA: Bam Buffer"):
This is usually followed by the "ORA-06508: PL/SQL: could not find program unit being called" error.
This is likely to be caused by fragmentation within the shared pool, such that there is insufficient contiguous free memory to load entire PL/SQL packages.
The solution is to increase the "shared_pool_reserved_size" parameter in the "init.ora" parameter file. This defaults to 5% of the shared pool, which may be fine if a large shared pool, but not if a small one (where majoriry is used by large PL/SQL objects).