"매 program 매 lifetime 동안 의 allocation/deallocation 의 전략". 매 manual (C/C++) ↔ ARC (Swift/ObjC) ↔ tracing GC (V8/JVM) ↔ ownership (Rust) — 매 spectrum 의 각 trade-off — 매 2026 의 mainstream 4 가지 paradigm 의 공존.
매 핵심
매 4 가지 paradigm
Manual: malloc/free, new/delete — 매 control 최대, 매 leak 위험.
Reference counting: ARC, shared_ptr — 매 deterministic, 매 cycle 문제.
Tracing GC: V8, JVM, .NET — 매 productivity, 매 pause.
Ownership: Rust borrow checker — 매 zero-runtime overhead, 매 learning curve.
매 핵심 metric
RSS (resident set size): 매 OS 시점.
Heap used: 매 runtime 시점.
External: 매 native buffer (Node Buffer).
Fragmentation: 매 allocate 가능하지만 매 contiguous block 부재.
매 응용
매 long-running server 의 stability.
매 game engine 의 frame budget.
매 embedded 의 RAM 의 limit.
💻 패턴
매 manual (C)
char*buf=malloc(1024);if(!buf){perror("malloc");exit(1);}// ... use ...
free(buf);buf=NULL;// 매 dangling 의 방지
매 RAII (C++)
{std::unique_ptr<MyObj>p=std::make_unique<MyObj>();// 매 scope exit 매 자동 delete
}std::shared_ptr<MyObj>sp=std::make_shared<MyObj>();// 매 ref-count 0 매 free
매 ownership (Rust)
fntake(s: String){/* 매 drop on end */}letowned=String::from("hi");take(owned);// println!("{}", owned); // 매 compile error: moved
매 tracing GC (JS)
letcache=newMap();cache.set('a',{big:newArray(1e6)});cache=null;// 매 GC 의 next cycle 의 reclaim
// 매 WeakMap 매 key 의 GC 자동 cleanup
constwm=newWeakMap();
node --inspect app.js
# Chrome DevTools → Memory → Take snapshot → 매 sample 3 개 → comparison view
node --heapsnapshot-signal=SIGUSR2 app.js
kill -USR2 $(pgrep node)
매 pool allocator
classPool{std::vector<MyObj*>free_;public:MyObj*acquire(){if(free_.empty())returnnewMyObj();auto*p=free_.back();free_.pop_back();returnp;}voidrelease(MyObj*p){free_.push_back(p);}};// 매 hot path 매 alloc 의 amortize
매 arena (Rust bumpalo)
usebumpalo::Bump;letarena=Bump::new();lets=arena.alloc(String::from("hi"));letv=arena.alloc(vec![1,2,3]);// 매 arena drop 매 모두 free — 매 deallocation O(1)
매 결정 기준
상황
Approach
매 systems / kernel
manual + sanitizer
매 high-perf game
RAII + pool
매 server productive
tracing GC + tune
매 safety + perf
Rust ownership
매 short-lived bulk
arena
기본값: 매 language idiom 따름 — 매 C++ RAII, 매 JS GC, 매 Rust ownership.