flâneur — a map of the web's best reading

Memory Allocation in Go | Melatoni

nghiant3223.github.io · 11,126 words · saved by 2 readers

This blog post primarily focuses on Go 1.24 programming language running on Linux on ARM architecture. It may not cover platform-specific details for other operating systems or hardware architectures. The content is based on other sources and my own understanding of Go, so it might not be entirely accurate. Feel free to correct me or give suggestions in the comment section at the very bottom 😄. Memory allocation is at the heart of every programming language runtime, and Go is no exception. Efficient allocation and management of memory directly affect the performance, scalability, and responsiveness of Go applications. While Go abstracts away most of the complexity through its simple APIs (new(T), &T{} and make), understanding what happens under the hood gives us valuable insight into how the runtime achieves efficiency, and where potential bottlenecks may arise. In this post, we’ll explore Go’s memory allocator in depth. We’ll look at its core components, how they interact to serve al

Memory Allocation in Go | Melatoni Memory Allocation in Go Contents Introduction Go’s View of Virtual Memory Arena and Page Span and Size Class Span Class Span Set Heap Bits and Malloc Header Heap Management Span Allocation: mheap.alloc Central Span Manager: mcentral Processor’s Memory Allocator: mcache Heap Allocation Tiny Objects: mallocgcTiny Small Objects: mallocgcSmall* Large Objects: mallocgcLarge Stack Management Allocating Stack: stackalloc Stack Growth: morestack Reusing Stack: stackfree Stack or Heap? Case Studies Disclaimer This blog post primarily focuses on Go 1.24 programming lan

Explore this link on the map →

saved by

related reading