개발 기록이

[ERROR] tomcat 서버 There is insufficient memory for the Java Runtime Environment 본문

Error 모음집

[ERROR] tomcat 서버 There is insufficient memory for the Java Runtime Environment

studyingbackhoe 2024. 7. 18. 20:30

톰캣 서버를 재기동해도 서버가 올라오지 않아 log를 확인해 보니 다음과 같은 에러가 발생했다. 

org.apache.catalina.startup.TldConfig execute
정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
org.apache.catalina.startup.HostConfig deployDirectory
정보: Deployment of web application directory /home/project/webapps has finished in 133 ms
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000072e300000, 1589641216, 0) failed; error='메모리를 할당할 수 없습니다' (errno=12)
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (mmap) failed to map 1589641216 bytes for committing reserved memory.

 
대표적인 원인 2가지가 있는데 
 
1. 물리적인 RAM의 부족
2. JVM 메모리 설정 문제
 
필자의 경우 RAM 크기를 늘려줄 수 있는 상황이 안 돼서  2번 방법을 사용했다.
 

해결방법

JAVA_OPTS 환경 변수로 힙 메모리 설정을 변경하여 Tomcat이 사용하는 JVM 메모리 설정을 조정해 줬다. startup.sh 에 기존에 작성된 export JAVA_OPTS="-Xms1G -Xmx2G" 를 export JAVA_OPTS="-Xms512m -Xmx1024m" 로 힙 메모리를 줄인 후 재기동하여 해결되었다.

  • Xms: 초기 힙 메모리 크기
  • Xmx: 최대 힙 메모리 크기

 

에러 원인

처음에는 JAVA_OPTS의 설정이 JVM이 요구하는 메모리 > 시스템에 실제로 사용 가능한 물리적 메모리 인 상황이었기 때문에 메모리 설정을 줄여서 시스템이 감당할 수 있는 JVM 메모리 크기로 변경하면 된다.
 


출처 : https://oingdaddy.tistory.com/151
https://hororolol.tistory.com/381
OpenAI ChatGPT (https://openai.com)
https://icon-icons.com/