---
title: "Size-Specialized Memory Allocation"
description: "Go 1.27 adds size-specialized variants of the runtime's mallocgc for allocations of 80 bytes or fewer, one per span class (size class plus pointer/no-pointer), making these allocations 20-30% faster and allocation-heavy programs up to 1% faster."
url: "https://swe.quest/articles/size-specialized-memory-allocation-cb92a01eba7d925f"
canonical: "https://go.dev/blog/size-specialized-allocations"
source: "The Go Blog"
published: "2026-09-16"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 7
tags: ["memory-management","go","runtimes","performance"]
---

# Size-Specialized Memory Allocation

A post on [The Go Blog](https://swe.quest/sources/go.md), published 2026-09-16, 7 min read, Deep dive. Original: [https://go.dev/blog/size-specialized-allocations](https://go.dev/blog/size-specialized-allocations)

## Summary

Go 1.27 adds size-specialized variants of the runtime's mallocgc for allocations of 80 bytes or fewer, one per span class (size class plus pointer/no-pointer), making these allocations 20-30% faster and allocation-heavy programs up to 1% faster. The compiler calls a specialized function directly when the size is known at compile time; otherwise mallocgc dispatches to it dynamically. Most of the gain comes from clearing memory with constant-size inline instructions instead of calling memclrNoHeapPointers, plus precomputed span classes, cheaper pointer bookkeeping and forced inlining. The functions are produced by a go/ast-based generator to keep copies in sync, and the 80-byte cutoff balances speed against binary size and instruction cache pressure. It can be disabled with GOEXPERIMENT=nosizespecializedmalloc.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- Go runtime basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- heap allocation and size classes
- garbage collection concepts ([easy posts on Memory management](https://swe.quest/tags/memory-management.md?difficulty=easy))
- instruction cache effects ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))

## Keywords

Go 1.27, mallocgc, size classes, span class, memclrNoHeapPointers, go/ast, GOEXPERIMENT

## Related posts

- [How we tracked down a Go 1.24 memory regression across hundreds of pods](https://swe.quest/articles/how-we-tracked-down-a-go-1-24-memory-regression-across-hundreds-of-pods-bbf00972d141a71d.md): Datadog Engineering · 2025-07-17 · Medium · 9 min read · Go, Memory management, Debugging, Performance engineering, Runtimes & VMs
  Upgrading a data-processing service to Go 1.24 raised container memory by about 20% even though Go runtime metrics and heap profiles stayed flat.
- [Understanding Garbage Collection in JavaScriptCore From Scratch](https://swe.quest/articles/understanding-garbage-collection-in-javascriptcore-from-scratch-6bc19cc2aad39444.md): WebKit · 2022-07-29 · Hard · 52 min read · Memory management, Runtimes & VMs, JavaScript, Concurrency
  JavaScriptCore's garbage collector is non-compacting, generational and mostly concurrent, with heavy use of lock-free programming.
- [Go Turns 17](https://swe.quest/articles/go-turns-17-44df44064c6960cc.md): The Go Blog · 2026-11-10 · Easy · 12 min read · Go, Performance engineering, Developer tools, Cryptography, Memory management
  Go's 17th anniversary recap covers Go 1.26 and 1.27. On the language side, it adds generic methods, self-referential constraints, \`new\` with an initial value, and nested struct literal keys.
- [V8 release v6.9 · V8](https://swe.quest/articles/v8-release-v6-9-v8-d0efd26e2594b2df.md): V8 · 2018-08-07 · Easy · 4 min read · Runtimes & VMs, JavaScript, Memory management, WebAssembly, Compilers
  V8 v6.9 embeds built-in functions directly into the binary on x64, so all Isolates share one copy instead of each holding up to 700 KB on its own heap.
- [Speculative Optimizations for WebAssembly using Deopts and Inlining](https://swe.quest/articles/speculative-optimizations-for-webassembly-using-deopts-and-inlining-bb89e7c53ac7945f.md): V8 · 2025-06-24 · Hard · 17 min read · WebAssembly, Compilers, Runtimes & VMs, Performance engineering
  V8 in Chrome M137 adds speculative call\_indirect inlining and deoptimization support for WebAssembly, using runtime call-target feedback gathered by the Liftoff baseline compiler so TurboFan can inline up to four likely callees behind cheap instance and target checks.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
