# Visualizing Go's Green Tea Garbage Collector and Its Heap Behavior

Original title: Watching Go's new garbage collector move through the heap

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

▲ 256 · by [matheusmoreira](<https://news.ycombinator.com/user?id=matheusmoreira>) · 💬 42
[original](<https://theconsensus.dev/p/2026/07/19/observing-gos-garbage-collector-old-and-new.html>) · [HN discussion](<https://news.ycombinator.com/item?id=49045474>)

## Summary

I explore how Go 1.26's default Green Tea garbage collector organizes memory by grouping objects of similar sizes, contrasting this with C#'s more scattered approach. Using custom tools, I visualize the heap to demonstrate Go's non-moving allocation strategy and highlight a specific challenge where sparse pages remain unreclaimed, revealing both the efficiency and limitations of this new collector.

## Key quote

> Go's non-moving collector cannot reclaim sparse pages.

## HN discussion (42 comments)

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

> This was very interesting, but the ending was a bit abrupt. I was under the impression that there was something more that I was missing under the subscribe banner.
>
> But to the point of the article - are there cases in which manually moving objects around to compact them in a specific area is done with golang? I don't use golang that much, and I'm sure that there are very strong arguments for not compacting the heap post-GC, but I've always wondered how it avoids crashing in the 0.0001% of cases in which heap is defragmented in such a way that there's no way to allocate a new large object

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

> For anyone interested in this - https://www.youtube.com/watch?v=gPJkM95KpKo

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

> The heap visualization is a great way to make GC behavior less abstract. It's interesting to see how much impact memory layout and cache locality can have, not just the GC algorithm itself.

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

> Excellent optimization technique: manually copying objects to a new slice so they don't prevent the GC from releasing memory by sitting right in the middle of a page it intends to free.

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

> It would be useful to include some practical tips on how developers can observe GC behaviour in their own applications using profiling tools

---

## Cite

- Page: https://zeli.app/story/49045474
- Date: 2026-07-25
- Source: theconsensus.dev (https://theconsensus.dev/p/2026/07/19/observing-gos-garbage-collector-old-and-new.html)
- Hacker News: https://news.ycombinator.com/item?id=49045474

## Other languages

- zh: https://zeli.app/zh/story/49045474 · markdown: https://zeli.app/zh/story/49045474.md
