Real-Time Analysis
Inline annotations show byte offsets, sizes, alignment requirements, and padding for every struct field as you type. No manual calculation needed.
Reduce memory usage by 10-30% with real-time visualization of struct layout, padding, and alignment
type User struct {
Active bool // 1 byte + 7 padding
ID uint64 // 8 bytes
Name string // 16 bytes
Age uint8 // 1 byte + 7 padding
Balance float64 // 8 bytes
}
type User struct {
ID uint64 // 8 bytes
Balance float64 // 8 bytes
Name string // 16 bytes
Active bool // 1 byte
Age uint8 // 1 byte + 6 padding
}
Everything you need to optimize Go struct memory layout
Inline annotations show byte offsets, sizes, alignment requirements, and padding for every struct field as you type. No manual calculation needed.
Automatically reorder struct fields to minimize memory usage and eliminate wasteful padding. CodeLens integration for instant optimization.
Visual warnings highlight wasteful padding bytes with configurable thresholds. Quickly identify structs that need optimization.
Switch between amd64, arm64, and 386 architectures to see how struct layouts differ across platforms. Essential for cross-platform Go development.
Automatically calculates memory layout for structs containing other custom struct types. Full recursive analysis of complex data structures.
Export detailed memory layout analysis to JSON, Markdown, or CSV formats. Perfect for documentation and code reviews.
Calculate struct size for different architectures in real-time
Watch how the extension analyzes and optimizes struct memory layout
An API response struct wastes 11 bytes (20%) due to poor field ordering. The extension detects this instantly:
The extension shows exactly where padding waste occurs and fixes it with one click.
Typically 10-30% memory reduction depending on your struct's field types. Structs with mixed bool, int, and string fields see the largest improvements. The exact savings depend on field count and type distribution.
Yes. Proper field ordering reduces padding bytes, which improves CPU cache locality. This can lead to 5-20% performance improvements in memory-intensive applications like API servers and data processing pipelines.
Order fields from largest to smallest alignment: pointers/strings/slices (8 bytes on 64-bit), then int64/float64, then int32/float32, then int16, finally bool/int8. This minimizes padding between fields.
Go aligns fields to their natural alignment boundaries for CPU efficiency. A uint64 must start at an 8-byte boundary. If preceded by a bool (1 byte), 7 bytes of padding are inserted to maintain alignment.
Yes. Go Memory Visualizer automatically detects and calculates layouts for nested custom struct types, giving you accurate sizes for complex data structures with embedded types.
The extension supports amd64 (64-bit x86), arm64 (64-bit ARM), and 386 (32-bit x86). Struct layouts can differ between architectures due to pointer size and alignment differences.
Get started in under a minute
ext install RhinoSoftware.go-memory-visualizer$ git clone https://github.com/1rhino2/go-memory-visualizer.git
$ cd go-memory-visualizer
$ npm install
$ npm run compile
Press F5 in VS Code to launch the Extension Development Host
Create or open any .go file containing struct definitions. The extension activates automatically.
Inline annotations appear showing offset, size, alignment, and padding for each struct field in real-time.
Click the "Optimize struct" CodeLens above any struct to automatically reorder fields for minimal memory usage.
Memory layout optimization matters for production Go applications
Smaller structs mean fewer memory allocations, reduced garbage collector pressure, and lower cloud hosting costs at scale. Save money on every deployment.
Optimal field ordering improves CPU cache locality, leading to faster data access and better overall throughput. Critical for high-performance Go services.
Learn exactly how Go lays out data in memory. Make informed design decisions about your data structures and write more efficient Go code.