가비지 컬렉션: 자동 메모리 관리
사용되지 않는 메모리를 자동으로 회수하는 기능.
In high-level languages like Java, C#, and JavaScript, developers don't need to manually free memory. The Garbage Collector periodicially scans the 'heap' to find objects that have no active references. By automating this, GC prevents common bugs like memory leaks and 'use-after-free' errors. However, GC can introduce latency due to 'stop-the-world' pauses where the application must wait for the collector to finish. Modern collectors minimize this using parallel or concurrent algorithms.
graph LR
Center["가비지 컬렉션: 자동 메모리 관리"]:::main
Rel_memory_management["memory-management"]:::related -.-> Center
click Rel_memory_management "/terms/memory-management"
Rel_cpu_cache["cpu-cache"]:::related -.-> Center
click Rel_cpu_cache "/terms/cpu-cache"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 5살도 이해할 수 있게 설명
다 놀고 난 장난감을 자동으로 치워주는 로봇 청소기 같은 기능입니다. 덕분에 방이 어지러워지지 않아요.
🤓 Expert Deep Dive
Tracing GC (like Mark-Sweep) builds a graph of all reachable objects starting from 'roots' (stack, globals). Refence Counting (used in Python/Swift) immediately deletes objects when their count hits zero. Generational GC leverages the 'weak generational hypothesis': that most objects die young. It divides the heap into 'Eden', 'Survivor', and 'Tenured' spaces, collecting the younger spaces more frequently.