template<size_t PoolSize> class PathfindingMemoryPool std::array<uint8_t, PoolSize> pool; std::bitset<PoolSize / MinBlockSize> allocMap; public: void* allocate(size_t size) // O(1) block allocation, no fragmentation ; Instead of storing per-unit pathfinding grids, use a spatial hash map to share path calculations among units within a 5-meter radius. This reduces memory by 70% for large formations. 4.3 Particle Leak Fix Implement RAII for particle effects:
~12 MB per minute during sustained artillery bombardment. 3.3 Fragmentation Due to the game's use of the default malloc allocator, the heap became severely fragmented after 30 minutes. Even though total free memory existed (e.g., 800 MB), the largest contiguous block was under 128 KB, causing large allocation requests (e.g., for terrain LOD textures) to fail. 4. Mitigation Strategies We propose three categories of solutions, ranging from user-level workarounds to source-level fixes. 4.1 Immediate User Workarounds | Setting | Effect | |---------|--------| | Reduce unit cap to 4,000 | Lowers pathfinding memory by 60% | | Disable "High Quality Particles" | Eliminates particle leak source | | Lower texture quality to Medium | Reduces static allocation by ~400 MB | 4.2 Developer-Focused Fixes 4.2.1 Enable Large Address Aware (LAA) If not already enabled, set the LAA flag in the executable header: cossacks 3 out of memory
editbin /LARGEADDRESSAWARE Cossacks3.exe This expands user-mode virtual address space from 2 GB to 4 GB (or 3.5 GB effective). Replace dynamic allocations for unit waypoints with a fixed-size pool: 16 GB RAM
class ParticleEffect ~ParticleEffect() if (particleBuffer) free(particleBuffer); ; And enforce culling logic in CParticleManager::OnFrameEnd() . We tested three scenarios on an Intel i7-9700K, 16 GB RAM, Windows 10 64-bit. Windows 10 64-bit.