"매 generational GC 의 short-lived object region". 매 1984 Lieberman & Hewitt 의 매 generational hypothesis ("most objects die young") 매 base. 매 V8 의 New Space (Scavenger), 매 JVM 의 Young Gen (Eden + 2 Survivor), 매 .NET 의 Gen 0/1 — 매 모두 매 동일한 idea: 매 young object 매 cheap copy + 매 old object 매 promote.
매 핵심
매 generational hypothesis
매 90%+ object 매 매 first GC cycle 의 die.
매 survivor 매 long-lived 가능 매 high.
매 separate region + 매 separate algorithm 매 efficient.
매 V8 New Space 구조
매 to-space + from-space (semispace).
매 Cheney's Scavenge (Cheney 1970) — 매 BFS copy.
매 size 매 1-8MB per isolate (V8 12+ adaptive).
매 minor GC: 매 < 1ms typical.
매 promotion: 매 2회 survive 시 Old Space 로 이동.
매 JVM Young Gen 구조
매 Eden (allocation site) + Survivor 0 + Survivor 1.
매 Eden full → 매 minor GC → 매 live → S0 (or S1).
매 매 매 Tenuring threshold (default 15) 도달 → Old Gen.
// 매 hot loop 의 ephemeral 의 ㅇ
functionprocessStream(items: Item[]){for(constitemofitems){consttmp={x: item.x*2,y: item.y*2};// 매 New Space alloc
emit(tmp);// 매 die immediately — minor GC 의 reclaim
}}// 매 X — 매 long-lived array 의 promotion
constcache: Record<string,Result>={};functionbad(item: Item){cache[item.id]=compute(item);// 매 Old Space promotion
}
// V8 internal: AllocationSite 가 매 history 추적 → 매 large/long-lived 매 immediate Old.
// 매 user-facing API X — 매 V8 의 implicit.
// 매 application 의 hint: 매 reuse object pool.
6. Object pool (allocation pressure 회피)
classVec3Pool{privatepool: Vec3[]=[];acquire():Vec3{returnthis.pool.pop()??newVec3();}release(v: Vec3){v.set(0,0,0);if(this.pool.length<1000)this.pool.push(v);}}// 매 매 frame 의 allocation 의 X → minor GC 매 silent
7. .NET Gen 0 stats
GC.Collect(0);// 매 Gen 0 (Young) 매 onlyConsole.WriteLine($"Gen0: {GC.CollectionCount(0)}");Console.WriteLine($"Gen1: {GC.CollectionCount(1)}");Console.WriteLine($"Gen2: {GC.CollectionCount(2)}");
매 결정 기준
상황
New Space tuning
Allocation-heavy (web server)
매 large New Space (V8 64-256MB) — 매 Scavenge frequency 줄임
Long-lived state (cache)
매 small New Space — 매 promote fast
Latency-critical (game)
매 object pool + 매 zero-alloc hot path
Memory-tight (mobile)
매 default + GC tuning 의 X
Long debugging session
--trace-gc + heap snapshot
기본값: 매 V8 default New Space + 매 hot path 의 object pool 사용.
언제: 매 GC pause 매 SLO 위협. 매 allocation profiling 매 hot path 식별. 매 V8 / JVM heap behavior 의 understanding.
언제 X: 매 Rust / C++ (no GC). 매 small script (default 면 충분). 매 micro-optimization 의 매 measurement 의 X.
❌ 안티패턴
매 frame 의 새 closure: 매 frame 마다 매 object alloc → 매 Scavenge 폭발.
Long-lived array 의 매 push/splice: 매 internal buffer 의 New Space alloc → promote.
TypedArray 의 매 매 new 만들기: 매 reuse — 매 Float32Array 매 large allocation.
매 GC 의 force (global.gc()): 매 production 의 X — 매 V8 heuristic 의 disrupt.
매 NewRatio 매 production 의 변경 의 측정 없이: 매 application-specific tuning — default 매 first.