The error ORA-04031 occurs on the shared pool which can indicate one of two things:
1) Insufficient space for the shared pool
2) Although there is enough memory, it is fragmented and no contiguous chunk can be allocated to satisfy the latest memory request.
SQL>alter system set “_enable_shared_pool_durations” = false scope=spfile;
SQL>System altered (output)