chore: JVM 메모리 설정 및 Hibernate 쿼리 플랜 캐시 축소#536
Conversation
- Xms128m/Xmx256m으로 힙 메모리 상하한 고정하여 과도한 메모리 예약 방지 - MaxMetaspaceSize=128m으로 Metaspace 상한 설정 - UseStringDeduplication으로 String 중복 제거로 메모리 절약 - AlwaysPreTouch로 시작 시 힙을 물리 메모리에 미리 할당 - GC 로그를 순환 파일로 저장하여 OOM 원인 파악 가능 - HeapDumpOnOutOfMemoryError로 OOM 발생 시 자동 힙 덤프 생성 - Hibernate query plan cache를 2048→64로 축소하여 ATNConfig 파서 객체 누적 방지
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 18 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 Walkthrough개요Dockerfile의 JVM 시작 명령어에 메모리 할당, 메타스페이스 제한, 문자열 중복 제거, GC 로깅, 힙 덤프 설정 등의 런타임 플래그를 추가했습니다. 또한 Hibernate 쿼리 캐시 튜닝 속성을 application-db.yml에 추가했습니다. 변경 사항
예상 코드 리뷰 소요 시간🎯 2 (Simple) | ⏱️ ~8분 관련 가능성 있는 PR
시 🐰
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Dockerfile`:
- Line 26: Remove the JVM flag "-XX:+AlwaysPreTouch" from the Dockerfile JVM
options list because it forces full heap page allocation at startup (increases
startup time and RSS); locate the place where JVM arguments are assembled (the
entry containing the string "-XX:+AlwaysPreTouch") and delete that flag (or
conditionally omit it for production images) so the JVM uses the default
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1f0f44e4-794c-46a8-9cfb-1c8230714cb3
📒 Files selected for processing (2)
Dockerfilesrc/main/resources/application-db.yml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Code Style Check
- GitHub Check: Analyze (java-kotlin)
🧰 Additional context used
📓 Path-based instructions (1)
**/*
⚙️ CodeRabbit configuration file
**/*: 공통 리뷰 톤 가이드:
- 모든 코멘트는 첫 줄에
[LEVEL: ...]태그를 포함한다.- 과장된 표현 없이 사실 기반으로 작성한다.
- 한 코멘트에는 하나의 이슈만 다룬다.
- 코드 예시가 필요하면 최소 수정 예시를 제시한다.
- 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.
Files:
src/main/resources/application-db.ymlDockerfile
🔇 Additional comments (1)
src/main/resources/application-db.yml (1)
28-30: [LEVEL: INFO] Hibernate 쿼리 플랜 캐시 축소 설정은 변경 목적과 일치합니다.Line 28-30 설정 경로(
spring.jpa.properties.hibernate.query.*)와 값 선언이 일관되어, 메모리 절감 목적의 튜닝 변경으로 자연스럽습니다.
- 시작 시 전체 힙 페이지를 물리 메모리에 할당하여 시작 시간과 RSS 증가 - 기본 lazy allocation 동작으로 되돌림
🔍 개요
해당 프로젝트의 서버 메모리 사용량은 약
500MB를 차지하는 중프로젝트 규모에 비해 너무 많은 메모리를 사용한다고 판단하여 원인 파악을 시작
힙 덤프 분석 결과 실제 힙 사용량은 약

85MB로, 원인은 힙이 아닌 다른 영역에 있을 것이라 추측또한 무엇인지 모르는
ATNConfig의 힙 사용량이 5%나 차지하는 것을 관측원인
힙 덤프 분석 결과 실제 힙 사용량은 약
85MB로, 나머지415MB는Metaspace,Thread Stacks,JVM내부 메모리 등에서 사용 중원인:
Dockerfile에JVM메모리 설정(-Xmx등)이 없어JVM이 기본값으로 과도한 메모리를 예약2GiB를 차지하는데, 따로 설정이 없으면1/4크기로 지정됨Hibernate HQL파서(ANTLR4)의ATNConfig객체가 132,873개 누적되어 약4.25MB점유Hibernate Query Plan Cache기본 크기(2048)가 과대 설정🚀 주요 변경 내용
Dockerfile
-Xms128m/-Xmx256m: 힙 메모리 상하한 고정하여 과도한 메모리 예약 방지-XX:MaxMetaspaceSize=128m: Metaspace 상한 설정-XX:+UseStringDeduplication: 중복 String 인스턴스(210K개) 메모리 절약-XX:+AlwaysPreTouch: 시작 시 힙을 물리 메모리에 미리 할당하여 런타임 지연 및 OOM 조기 발견-Xlog:gc*:file=/app/gc.log:time,uptime,level,tags:filecount=5,filesize=10m: GC 로그 순환 저장-XX:+HeapDumpOnOutOfMemoryError/-XX:HeapDumpPath=/app/heapdump.hprof: OOM 발생 시 자동 힙 덤프 생성application-db.yml
hibernate.query.plan_cache_max_size: 2048 → 64hibernate.query.plan_parameter_metadata_max_size: 128 → 32💬 참고 사항
-Xmx값 증량 필요✅ Checklist (완료 조건)