# noalloc forces Go code to stay allocation-free as it changes

Original title: noalloc: Tooling and libraries to enforce zero heap allocations in Golang

> Hacker News story 50278645 · language: en · submitted 2026-10-28
> Web version: https://zeli.app/story/50278645
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 81 · by [g0xA52A2A](<https://news.ycombinator.com/user?id=g0xA52A2A>) · 💬 57
[original](<https://github.com/theconsensuslabs/noalloc>) · [HN discussion](<https://news.ycombinator.com/item?id=50278645>)

## Summary

noalloc is a tool and library set that lets you mark Go functions with //noalloc:root and then checks the entire call tree for heap allocations, reporting every offending line. It also ships bounded, fixed-capacity containers (Buf, Vec, Slice, Map) and a zero-allocation JSON encoder/decoder generated by jsongen. The repo is AI-written but used in production at The Consensus; it requires Go 1.27 or later and exits with code 1 on any allocation found.

## Key quote

> It's one thing to be able to write some code that doesn't allocate on the heap. It's another thing to be able to keep code from not allocating as the code changes.

## HN discussion (57 comments)

### [eatonphil](<https://news.ycombinator.com/item?id=50294088>)

> Hey folks, this is my project. I really liked OxCaml's zero_alloc feature [0], something you don't get in Rust or Zig or Go*, and have been trying to get a handle on allocations in The Consensus's code search engine.
>
> It's an extremely early project but it's been helping me out a bunch already. Would love to hear your bug reports or requests if you try running it on your codebase.
>
> [0] https://theconsensus.dev/p/2026/06/27/the-feature-in-oxcaml-...
>
> \* I think you can get this in Clang and maybe GCC with `__attribute__((nonallocating))` though.

### [andrewla](<https://news.ycombinator.com/item?id=50293009>)

> The end state of every garbage collected language is a suite of tools to prevent garbage collection at all costs.
>
> I think we can learn something here.

### [gritzko](<https://news.ycombinator.com/item?id=50294165>)

> If you don't allocate, why do you even need Go or Rust? LLMs handle less elegant syntax just as well. I use a zero-malloc C dialect with slices and bounds-checking.
>
> Just recently I was sketching a smallish database in zero-malloc C. https://replicated.live/blog/db That was partly because most LSM data structures are read-only, so mmap was good enough and concurrent access was safe for the bulk of the data.
>
> The "hot zone" (memtable) then requires some intricate engineering, but that is the case either way.
>
> You can go quite far with zero-malloc C.

### [kvemkon](<https://news.ycombinator.com/item?id=50293378>)

> Go compiler has an advanced escaping analyzer. Wouldn't it be easier and better to add this noalloc-analyzer feature to golang directly?

### [zinodaur](<https://news.ycombinator.com/item?id=50292051>)

> I love it. Any thoughts on allowing (value type) Pointers into a Region?

---

## Cite

- Page: https://zeli.app/story/50278645
- Date: 2026-10-28
- Source: github.com (https://github.com/theconsensuslabs/noalloc)
- Hacker News: https://news.ycombinator.com/item?id=50278645

## Other languages

- zh: https://zeli.app/zh/story/50278645 · markdown: https://zeli.app/zh/story/50278645.md
- ja: https://zeli.app/ja/story/50278645 · markdown: https://zeli.app/ja/story/50278645.md
- ko: https://zeli.app/ko/story/50278645 · markdown: https://zeli.app/ko/story/50278645.md
- de: https://zeli.app/de/story/50278645 · markdown: https://zeli.app/de/story/50278645.md
- es: https://zeli.app/es/story/50278645 · markdown: https://zeli.app/es/story/50278645.md
- ru: https://zeli.app/ru/story/50278645 · markdown: https://zeli.app/ru/story/50278645.md
