"매 generational heap + sandbox + pointer compression". V8 매 Young/Old Gen 의 분리 + Orinoco GC + 매 4GB sandbox 의 OOB exploit 의 mitigate. 2026 매 V8 12.x — 매 Maglev tier + Sparkplug + sandbox-by-default + Node.js 22 LTS.
매 핵심
매 Heap 구조
Young Generation — 매 short-lived: Nursery (To/From semi-space) + Intermediate.
Old Generation — 매 long-lived: Old Pointer Space + Old Data Space.
Large Object Space — 매 >256KB allocations.
Code Space — 매 JIT-compiled machine code.
Map Space — 매 hidden classes (V8 Maps).
Read-Only Space — 매 immutable VM-level data.
매 GC 알고리즘
Scavenger (Young): Cheney's copying — 매 minor GC, 매 ms 단위.
Major GC (Old): Mark-Sweep-Compact + concurrent/parallel/incremental.
Orinoco — main-thread pause 의 minimize.
매 V8 Sandbox (Memory Cage)
매 V8 heap 의 4GB virtual region 의 confine.
매 internal pointer 의 sandbox-relative 32-bit offset.
매 OOB write exploit 의 host process corrupt X.
매 V8 11.4+ default — 매 --sandbox flag.
매 Pointer Compression
매 64-bit isolate 의 32-bit offset 사용 (4GB heap).
매 메모리 의 ~40% 절감.
Cage base register + offset = full pointer.
매 Hidden Classes (Maps)
매 object shape descriptor.
매 inline cache (IC) 의 fast property access.
매 shape transition 의 monomorphic 유지 의 핵심.
매 응용
Node.js memory tuning — --max-old-space-size.
Memory leak debugging — heap snapshot.
JIT optimization — monomorphic code path.
Embedded V8 — Deno, Cloudflare Workers, Electron.
💻 패턴
Heap size tuning
# 4GB old generation
node --max-old-space-size=4096 server.js
# 256MB young generation (semi-space)
node --max-semi-space-size=128 worker.js
// GOOD — same shape every call → monomorphic IC
functionarea({w,h}){returnw*h;}area({w:1,h:2});area({w:3,h:4});// BAD — varied shapes → megamorphic, IC miss
area({w:1,h:2,label:"a"});area({w:3,h:4,color:"red"});
Hidden class stability
// BAD — late property addition forces shape transition
constu={};u.id=1;u.name="x";// GOOD — initialize all properties at construction
constu2={id:1,name:"x"};
언제: Node.js 의 production tuning, memory leak diagnosis, JIT optimization, V8 embedding.
언제 X: 매 SpiderMonkey/JavaScriptCore 의 generic 적용 X — 매 V8-specific.
❌ 안티패턴
매 late property addition: hidden class transition — IC miss.
매 too-small --max-old-space-size: OOM crash.
매 too-large heap: GC pause 의 증가.
매 closure 의 long-lived ref 유지: 매 leak.
매 megamorphic call site: deopt → slow path.
매 sandbox disable (--no-sandbox): 매 production 의 X.