ORA-04031: Unable to allocate N bytes of shared memory
Oracle의미
Oracle이 공유 메모리 풀(보통 shared pool 또는 large pool)에서 요청한 크기의 연속 메모리를 할당하지 못했다. SGA 구성 요소가 메모리 압박을 받고 있다.
원인
바인드 변수 없이(리터럴로 가득 찬) 고유한 SQL 문이 많아 생긴 shared pool 단편화, 부족한 SHARED_POOL_SIZE, 과도한 동시 접속, 대형 PL/SQL 패키지, 또는 잘못된 ASMM/AMM 크기 설정.
해결 방법
오류 메시지가 가리키는 풀(shared pool, large pool 등)을 확인한다. 단기 조치: ALTER SYSTEM FLUSH SHARED_POOL(주의: 운영 환경에서는 모든 SQL을 다시 파싱하게 되어 일시적인 hard parse 폭주가 발생하며, 단편화를 영구적으로 해결하지 않는다). 근본 해결: 바인드 변수 사용을 강제하고(CURSOR_SHARING 포함), SGA_TARGET / SHARED_POOL_SIZE / LARGE_POOL_SIZE를 늘린다. 자주 사용하는 패키지는 DBMS_SHARED_POOL.KEEP으로 메모리에 고정한다. 메모리 분포는 V$SGASTAT으로 확인한다.
같은 데이터베이스의 다른 항목
- ORA-01017Invalid username/password; logon denied
- ORA-01555Snapshot too old: rollback segment number too small
- ORA-01652Unable to extend temp segment by N in tablespace
- ORA-12154TNS: could not resolve the connect identifier specified
- ORA-12514TNS: listener does not currently know of service requested in connect descriptor
- ORA-00942Table or view does not exist
- ORA-01031Insufficient privileges