<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Allocator on Hammer's Blog</title><link>https://lkic1625.github.io/blog/allocator/</link><description>Recent content in Allocator on Hammer's Blog</description><generator>Hugo</generator><language>ko-kr</language><copyright>© 조원빈 - All rights reserved</copyright><lastBuildDate>Wed, 21 Oct 2026 13:01:48 +0900</lastBuildDate><atom:link href="https://lkic1625.github.io/blog/allocator/index.xml" rel="self" type="application/rss+xml"/><item><title>메모리 할당기: glibc, jemalloc, TCMalloc, Java, Go</title><link>https://lkic1625.github.io/os-memory-allocation/</link><pubDate>Wed, 21 Oct 2026 13:01:48 +0900</pubDate><guid>https://lkic1625.github.io/os-memory-allocation/</guid><description>&lt;h2 id="allocation-관련-정리">Allocation 관련 정리&lt;/h2>
&lt;p>Allocator는 기본적으로, 4가지 정도 존재한다.&lt;/p>
&lt;ol>
&lt;li>얼마나 빨리 할당할 수 있는가,
&lt;ol>
&lt;li>매번 커널 진입이 아닌, 미리 확보한 메모리를 Free List 를 통해 활요하는 Fast Path를 이용&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>얼마나 적은 메모리를 낭비하는가
&lt;ol>
&lt;li>단편화 문제를 어떻게 해결하는가, 실제 요청보다 더 큰 Block을 할당하거나, 여유 공간은 충분하지만 연속 공간을 효율적으로 반환하기 어려운 경우&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>동시성 확보를 위한 방식
&lt;ol>
&lt;li>여러 스레드가 요청하는 경우의 contention 관리&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>언제 메모리를 반환할 것인가.
&lt;ol>
&lt;li>실제 메모리가 다시 쓰일 확률이 높다면 이를 가지고 재사용하는 것이 합당하다
이 네 가지를 통해 실제 설계 철학들을 엿볼 수 있다. 또한, 현대의 메모리 할당기가 서로 배타적인 구현을 하는 것이 아니고, 각 방법에서 핵심 설계 관점을 다르게 보는 것이다.&lt;/li>
&lt;/ol>
&lt;/li>
&lt;/ol>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Allocator&lt;/th>
 &lt;th>핵심 설계 관점&lt;/th>
 &lt;th>대표적인 기법&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>glibc malloc (ptmalloc 계열)&lt;/td>
 &lt;td>범용성, 호환성&lt;/td>
 &lt;td>Arena, Thread Cache&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>jemalloc&lt;/td>
 &lt;td>단편화 관리, 메모리 사용량 제어&lt;/td>
 &lt;td>Multiple Arenas, Decay, Purging&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>TCMalloc&lt;/td>
 &lt;td>높은 병렬성과 빠른 할당&lt;/td>
 &lt;td>Per-CPU Cache, rseq, Hugepage-aware Allocation&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>mimalloc&lt;/td>
 &lt;td>낮은 경합, Locality, 메모리 효율&lt;/td>
 &lt;td>Free-list Sharding, Eager Purging&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>snmalloc&lt;/td>
 &lt;td>Cross-thread Free의 확장성&lt;/td>
 &lt;td>Message Passing&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Scudo&lt;/td>
 &lt;td>Heap 메모리 안전성&lt;/td>
 &lt;td>Metadata 검증, Quarantine, Randomization&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h3 id="tcache-glibc">tcache, glibc&lt;/h3>
&lt;pre tabindex="0">&lt;code>Thread 1 ── tcache ──┐
Thread 2 ── tcache ──┼── Arenas ── OS
Thread 3 ── tcache ──┘
&lt;/code>&lt;/pre>&lt;p>객체를 할당하고 해제하는데 필요한 정보를 스레드 별로 두어, lock 집중을 막는 방식&lt;/p></description></item></channel></rss>