Added one scratch, one engine and one game arena. Converted the game alloc to arena + the display stuff. WIP Made using Antigravity+gemini
2.3 KiB
2.3 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.
Remaining Work
The following subsystems still use legacy malloc/calloc/realloc/free and need to be migrated.
Hot Reload System
- Files:
Core/HotReload/HotReload.cpp,Core/HotReload/Win32/Win32HotReload.cpp - Allocations:
DLLFullPath,LockFullPath,tempDllPath. - Strategy:
- Use
EngineArenafor persistent paths (DLLFullPath,LockFullPath). - Use
ScratchArenafor temporary paths (tempDllPath).
- Use
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).