Go Developers
simon125q's profile
Szymon Omieciński@simon125q•Sep 18, 2025
25.3K
Post cover image

Memory Allocation in Go

From nghiant3223.github.io•Sep 17, 2025•53m read time

Go's memory allocator uses a hierarchical system with three main components: mheap manages coarse-grained memory pages and arenas, mcentral serves as an intermediary managing spans of different size classes, and mcache provides per-processor local allocation for tiny and small objects. The runtime partitions memory into 64MB arenas divided into 8KB pages, organizes objects into 68 size classes to minimize fragmentation, and uses span classes to optimize garbage collection by distinguishing between objects with and without pointers. The allocator employs various optimization strategies including per-processor caching, radix trees for efficient free page tracking, and specialized allocation paths for tiny, small, and large objects.

Sort:

simon125q's user avatar
Szymon Omieciński
@simon125q
Joined Aug 7. 2024
25.3K

Student | Backend | Go | Python | Linux | NeoVim

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard