View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0006169 | Spring engine | General | public | 2019-03-17 02:50 | 2019-03-19 23:18 | ||||
Reporter | Google_Frog | ||||||||
Assigned To | |||||||||
Priority | normal | Severity | crash | Reproducibility | have not tried | ||||
Status | resolved | Resolution | no change required | ||||||
Product Version | 104.0 +git | ||||||||
Target Version | Fixed in Version | 104.0 +git | |||||||
Summary | 0006169: 104.0.1-1085-gfc6d80e maintenance Failed to allocate memory with AI involved | ||||||||
Description | https://github.com/ZeroK-RTS/CrashReports/issues/20677 | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | Yes | ||||||||
Attached Files |
|
![]() |
|
Kloot (developer) 2019-03-17 18:14 Last edited: 2019-03-17 18:17 |
[PreGame::AddGameSetupArchivesToVFS] using map: AlienDesert [~ScopedOnceTimer][Game::LoadSkirmishAIs::CreateAI(id=0)] 68117ms no AI should need 68 seconds to initialize normally on a map like this, may have been a runaway (failed) allocation in CircuitAI. |
lamer (reporter) 2019-03-19 08:35 |
3564MB RAM, Win 7 AddressSanitizer (libasan) reported no memory leaks or corruptions inside AI. According to my valgrind run on linux64 engine+ZK uses about 2.5~2.7GB at first 2 minutes of play (--pages-as-heap=yes shows 4.8GB, i use valgrind for the 1st time, so lets say 2.5GB), that should be significant for a system with 3564MB only. Yet what's strange is that heaviest AI's memory allocation is coming from calling engine's CAICallback::GetUnitDefHeight to get height of a unit. It was recently added to solve water target selection. AI caches height for each possible UnitDef at the start, hence engine loads each model with all textures and whistles. How to workaround it? Attached results of 2-minute runs. I expected more memory usage because of per-AI threat, blocking and area maps for several types of units. Overall i see no critical issues within AI except for CAICallback::GetUnitDefHeight. $ valgrind --tool=massif --stacks=yes ./spring test_script.txt 1player vs 1AI; 4AI vs 4AI Map - Tundra ZK - v1.7.3.4 spring - 104.0.1-1091-g76dfb33 |
Kloot (developer) 2019-03-19 12:43 Last edited: 2019-03-19 12:44 |
> AI caches height for each possible UnitDef at the start, hence engine loads each model with all textures and whistles. How to workaround it? Implement some form of on-demand caching, i.e. UnitDefHeightCache::UnitDefHeightCache() { unitDefHeightCache.fill(-1.0f); // std::array<float, N> } float UnitDefHeightCache::Get(int unitDefID { float& height = unitDefHeightCache[unitDefID]; if (height < 0.0f) height = callback->GetUnitDefHeight(unitDefID); return height; } |
lamer (reporter) 2019-03-19 22:21 |
On-demand height initialization reduced memory usage by 500MB in above specific test case. https://github.com/spring/CircuitAI/pull/7 Now on start game uses about 1.9GB only. |
Kloot (developer) 2019-03-19 23:18 |
cool, one more for the NCR list |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2019-03-17 02:50 | Google_Frog | New Issue | |
2019-03-17 18:14 | Kloot | Note Added: 0019867 | |
2019-03-17 18:17 | Kloot | Note Edited: 0019867 | View Revisions |
2019-03-19 08:35 | lamer | File Added: valgrind_massif_result.zip | |
2019-03-19 08:35 | lamer | Note Added: 0019879 | |
2019-03-19 12:43 | Kloot | Note Added: 0019880 | |
2019-03-19 12:44 | Kloot | Note Edited: 0019880 | View Revisions |
2019-03-19 22:21 | lamer | Note Added: 0019882 | |
2019-03-19 23:18 | Kloot | Status | new => resolved |
2019-03-19 23:18 | Kloot | Resolution | open => no change required |
2019-03-19 23:18 | Kloot | Fixed in Version | => 104.0 +git |
2019-03-19 23:18 | Kloot | Note Added: 0019883 |