C++ Memory Layout Visualizer for VS Code
A project by IEEE Computer Society BMSIT&M
Developed by Atul K M
StructSight is a powerful VS Code extension that provides real-time visualization of C++ struct and class memory layouts. Get instant insights into memory padding, alignment, vtable layouts, and optimization opportunities - all while you code.
- Hover over struct/class definitions to see memory layout summaries
- Open detailed webview with complete memory map
- Visual representation of members, padding, and alignment
- Color-coded padding regions with explanations
- Visualize 64-byte cache line boundaries
- Detect members spanning multiple cache lines
- Optimize for cache-friendly data structures
- Automatic detection of excessive padding
- Suggested member reordering for size reduction
- "Can save X bytes" insights with confidence scores
- One-click refactoring to apply optimizations
- Switch between 32-bit (x86) and 64-bit (x64) architectures
- Compiler-specific layout rules (GCC, Clang, MSVC)
- See how your structs behave across different platforms
- Detect polymorphic classes automatically
- Visualize vtable pointer placement
- List all virtual functions
- Handle multiple inheritance scenarios
Install from the VS Code Marketplace:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "StructSight"
- Click Install
Windows:
- LLVM/Clang development libraries (pre-built binaries included)
- Visual Studio 2019 or later (for building from source)
Linux:
sudo apt-get install llvm-14-dev libclang-14-dev clang-14macOS:
brew install llvm- Hover Analysis: Hover over any
structorclasskeyword to see a quick summary - Detailed View: Click "Show Detailed Layout" or use command
StructSight: Show Memory Layout - Apply Optimizations: Click the "Apply Reordering" button in the webview or use VS Code's Quick Fix (Ctrl+.)
Configure StructSight through VS Code settings:
{
"structsight.architecture": "x64", // "x86" or "x64"
"structsight.compiler": "clang", // "gcc", "clang", or "msvc"
"structsight.cacheLineSize": 64, // Cache line size in bytes
"structsight.showPaddingBytes": true, // Highlight padding
"structsight.showOptimizationHints": true, // Show optimization suggestions
"structsight.enableHoverInfo": true // Enable hover provider
}struct BadLayout {
char a; // 1 byte
int b; // 4 bytes (3 bytes padding before)
char c; // 1 byte
double d; // 8 bytes (7 bytes padding before)
};
// Total: 24 bytes (10 bytes padding!)struct GoodLayout {
double d; // 8 bytes
int b; // 4 bytes
char a; // 1 byte
char c; // 1 byte
// 2 bytes tail padding
};
// Total: 16 bytes (only 2 bytes padding) - 33% size reduction!StructSight combines the power of Clang's LibTooling with VS Code's extension API:
- C++ Analysis Engine: Uses Clang AST to parse C++ code with compiler accuracy
- Native Node.js Addon: Exposes C++ analysis to TypeScript via N-API
- TypeScript Extension: Provides VS Code integration and UI
- React Webview: Interactive visualization of memory layouts
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Clone the repository
git clone https://github.com/yourusername/structsight.git
cd structsight
# Install dependencies
npm run install:all
# Build native addon
npm run build:native
# Build extension
npm run build:extension
# Run in development mode
code .
# Press F5 to launch extension development hostMIT License - see LICENSE for details
Developed by: Atul K M
Organization: IEEE Computer Society - BMSIT&M
Project Type: Educational Tool for C++ Developers
The IEEE Computer Society chapter at BMS Institute of Technology & Management is dedicated to fostering innovation and technical excellence in computer science and software engineering.
- Built with Clang's LibTooling
- Inspired by the need for better C++ memory layout understanding
- Thanks to the VS Code extension API team
- Special thanks to IEEE Computer Society BMSIT&M for supporting this project
Found a bug or have a feature request? Please open an issue!
Made with β€οΈ by IEEE CS BMSIT&M for C++ developers who care about performance


