Files
2nd/10_Wiki/Topics/DevOps_and_Security/자바 가상 머신(JVM).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

5.2 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-자바-가상-머신-jvm 자바 가상 머신(JVM) 10_Wiki/Topics verified self
JVM
Java Virtual Machine
HotSpot
OpenJDK
none A 0.9 applied
jvm
java
runtime
gc
jit
performance
2026-05-10 pending
language framework
java jvm

자바 가상 머신(JVM)

매 한 줄

"매 Write Once, Run Anywhere". 매 1995년 Sun Microsystems 의 의 의 release 의 stack-based bytecode 의 의 interpret 의 의 의 의 의 portable 의 runtime. 매 2026 — 매 OpenJDK 24 LTS, 매 ZGC sub-millisecond 의 의 GC 의 의 GraalVM native-image 의 의 의 의 의 의 의 startup.

매 핵심

매 JVM 의 의 의 components

  1. Class Loader — bytecode 의 load.
  2. Runtime Data Areas — heap / stack / metaspace / PC.
  3. Execution Engine — interpreter + JIT + GC.
  4. Native Interface (JNI) — C/C++ interop.

매 Memory areas

  • Heap — 매 object — Young (Eden + Survivor) + Old.
  • Metaspace — 매 class metadata (post Java 8, off-heap).
  • Stack — 매 thread 별 frame.
  • PC Register — 매 thread 별 instruction pointer.
  • Native Method Stack — 매 JNI 의 native frame.

매 2026 GCs

GC 매 특성 매 use case
G1 매 default, balanced 매 일반 server
ZGC 매 sub-ms pause, TB heap 매 low-latency
Shenandoah 매 concurrent compaction 매 large heap, low pause
Parallel 매 throughput 매 batch
Serial 매 single thread 매 small / embedded

매 JIT compilation tiers

  • Interpreter — 매 bytecode 의 직접 execute.
  • C1 (Client) — 매 빠른 compile, 적은 optimization.
  • C2 (Server) — 매 expensive compile, aggressive optimization.
  • Tiered compilation — 매 default — interpreter → C1 → C2.

매 GraalVM native-image

  • 매 AOT compile → 매 startup 의 ms.
  • 매 reflection 의 의 limit.
  • 매 serverless / CLI 의 의 ideal.

💻 패턴

매 GC tuning (production)

# 매 ZGC, low-latency
java \
  -XX:+UseZGC \
  -Xmx16g \
  -XX:+UseLargePages \
  -XX:+AlwaysPreTouch \
  -jar app.jar

# 매 G1, balanced
java \
  -XX:+UseG1GC \
  -Xmx8g \
  -XX:MaxGCPauseMillis=200 \
  -XX:G1HeapRegionSize=16m \
  -jar app.jar

매 JFR (Java Flight Recorder) profiling

# 매 production-safe profiler
java \
  -XX:StartFlightRecording=duration=60s,filename=app.jfr \
  -jar app.jar

# 매 분석 — JDK Mission Control
jmc app.jfr

매 Heap dump (OOM analysis)

java \
  -XX:+HeapDumpOnOutOfMemoryError \
  -XX:HeapDumpPath=/tmp \
  -jar app.jar

# 매 Eclipse MAT 의 의 의 분석

매 GraalVM native-image

# 매 Spring Boot 3.x 의 의 의 native build
./mvnw -Pnative native:compile
./target/app  # 매 50-100ms 의 의 의 의 startup

매 ClassLoader 의 의 의 dynamic loading

URLClassLoader loader = new URLClassLoader(
    new URL[]{ new URL("file:plugins/myplugin.jar") },
    getClass().getClassLoader()
);
Class<?> cls = loader.loadClass("com.example.Plugin");
Plugin plugin = (Plugin) cls.getDeclaredConstructor().newInstance();

매 JNI 의 의 의 native call

public class Native {
    static { System.loadLibrary("mynative"); }
    public native int process(byte[] data);
}
// mynative.c
JNIEXPORT jint JNICALL
Java_Native_process(JNIEnv *env, jobject obj, jbyteArray data) {
    // 매 C 의 fast processing
    return 0;
}

매 JMH (Java Microbenchmark Harness)

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int sum(BenchmarkState state) {
    int s = 0;
    for (int i : state.data) s += i;
    return s;
}

매 결정 기준

상황 Approach
매 latency-critical 매 service 매 ZGC + tiered JIT
매 batch / throughput 매 Parallel GC
매 serverless / CLI 매 GraalVM native-image
매 large heap (TB) 매 ZGC / Shenandoah
매 startup-critical 매 CDS (Class Data Sharing) + AOT

기본값: 매 OpenJDK 24 + G1 GC + tiered JIT + JFR enabled.

🔗 Graph

🤖 LLM 활용

언제: 매 JVM tuning, 매 OOM debug, 매 GC pause investigation, 매 native-image migration. 언제 X: 매 application logic — 매 JVM internals 의 의 의 abstract.

안티패턴

  • -Xmx == -Xms skip: 매 heap resize 의 의 의 GC pause spike.
  • Runtime.exec 의 의 의 abuse: 매 fork 의 의 의 expensive.
  • Reflection-heavy + native-image: 매 reachability 의 의 의 의 manual config 의 의 X 의 의 fail.
  • Finalize 의 의 의 reliance: 매 deprecated — 매 try-with-resources / Cleaner.
  • String concat in hot loop: 매 StringBuilder 의 의 의 X 의 garbage flood.

🧪 검증 / 중복

  • Verified — OpenJDK 24 docs (2026); Brian Goetz, Java Concurrency in Practice; Charlie Hunt, Java Performance.
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — JVM internals + 2026 GC/GraalVM stack