Files
2nd/10_Wiki/Topics/Domain_Programming/DevOps_and_Security/자바 가상 머신(JVM).md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +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