2.1 KiB
2.1 KiB
Memory System Status & Migration Plan
Completed Work
Core Systems
- MemoryArena: Implemented linear allocator with alignment, markers, and reset support.
- Global Arenas:
ScratchArena(64MB): Transient per-frame memory.EngineArena(256MB): Persistent engine memory (internal).GameArena(512MB): Persistent game memory (exported to Game DLL).
- Helpers: Added
ArenaPushType<T>andArenaPushArray<T>with automatic zero-initialization.
Migrated Subsystems
- Display:
Win32WindowandWin32DisplayDevicenow useEngineArena. - Game Entities:
Entity.husesGameArenafor entity allocation; manualfreecalls removed fromgame.cpp. - Hot Reload:
HotReload.cpp(persistent paths toEngineArena) andWin32HotReload.cpp(temp paths toScratchArena).
Remaining Work
The following subsystems still use legacy malloc/calloc/realloc/free and need to be migrated.
IO System
- Files:
Core/HAL/IO/IOStream.cpp,Core/HAL/IO/Win32/Win32IOStream.cpp - Allocations:
IOStreaminstance, data buffers,Win32IOStreamDataPayload. - Challenge:
Reallocis used for growing buffers. - Strategy:
IOStreamstruct ->ScratchArena(if transient) orEngineArena.- Buffers: Evaluate if
ArenaPushwith large enough capacity is sufficient, or implement a growable buffer on top of arena (or usestd::vectorwith custom allocator if absolutely needed, but prefer simple fixed max size if possible).
Graphics / Debug
- Files:
Graphics/DebugDisplayRenderer.cpp - Allocations:
DepthTestedVertices,OverlayVertices. - Strategy: Use
EngineArenaor a dedicatedRenderArenaif these are persistent. If per-frame, move toScratchArena.
Shader Compiler
- Files:
JulietShaderCompiler/ShaderCompiler.cpp - Allocations: Argument arrays, file buffers.
- Strategy: Use
ScratchArenafor all compilation tasks as they are transient.
Filesystem
- Files:
Core/HAL/Filesystem/Filesystem.cpp - Allocations:
CachedBasePath. - Strategy: Migrate to
EngineArena(persistent).