7.1 Structure Packing
- Use
#pragma pack or
__attribute__((packed)) for tight structures
- Order structure members by size (largest to smallest)
- Use appropriate data types (uint8_t instead of int where
possible)
7.2 Memory Alignment
- Align structures to their natural boundaries
- Use
alignas or __attribute__((aligned))
for critical structures
- PVR2 requires 8-byte alignment for textures
7.3 Memory Pooling
- Pre-allocate common object types
- Use object pools for frequently allocated objects
- Reduce malloc/free overhead