SB-007-MEMORY_MANAGEMENT.md
(P1, 327 lines)
- Memory management for constrained Dreamcast (16MB RAM, 8MB
VRAM)
- D3-TUI budget: ~6.5MB total (terminal buffer ~4MB, fonts ~1.5MB,
vertex buffers ~512KB, etc.)
- Architecture: Allocator Layer (Main/VRAM/Stack) + Debug Layer
(Tracking/Leak Detection/Stats)
- API: init/shutdown, malloc/calloc/realloc/free, vram_malloc/free,
debug variants with file/line info,
get_stats/print_stats/validate/dump_leaks
- Debug headers in D3TUI_DEBUG builds with magic numbers and
checksums
- Pool allocators for fixed-size objects (terminal cells)
- Structure packing, memory pooling, compression techniques
- Error handling: return NULL on OOM, OOM callback for custom
handling, corruption detection
- Performance targets: allocation < 0.1ms, overhead < 16 bytes
per allocation, fragmentation < 5%