7 ms·
Show HN: Go Memory Visualizer, real-time struct layout and auto optimization
Hey HN! I built a VS Code extension that shows you exactly how Go lays out your structs in memory and automatically fixes padding waste.
What it does:
Inline annotations showing byte offsets, sizes, and padding as you type
One-click optimization that reorders fields to eliminate waste
Diverse-architecture support (amd64, arm64, 386)
Hover for detailed memory layout info
Why it matters:
Poor field ordering in Go structs commonly wastes 10-30% of memory due to alignment padding. For example, a careless 56-byte struct can become 40 bytes just by reordering fields. At scale, this adds up — both in memory costs and cache performance.
Demo:
Before: 56 bytes
After auto-optimization: 40 bytes (-29%)
The extension highlights wasteful padding in real-time and offers a CodeLens button to fix it automatically.
Try it:
VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=RhinoSoftware.go-memory-visualizer https://marketplace.visualstudio.com/items?itemName=RhinoSof...
GitHub: https://github.com/1rhino2/go-memory-visualizer https://github.com/1rhino2/go-memory-visualizer
Built this after repeatedly optimizing structs manually in production code. Figured others might find it useful too.
Would love feedback on what other memory-related features would be helpful!