Map Close Crash Bugfix - Direct ApseMap.gfx Edit
🟡 Updated this yearPreview

🔍 Analysis
- 🏆 #210 of 264 User Interface mods in this game by downloads
📋 About This Mod
This mod resolves a bug Warhorse probably introduced in a recent patch that makes the map crash the game when you close it.
Installation instructions
Install in your \KingdomcomeDeliverance2\Mods\ folder like any other mod
Without this mod installed, open your windows resource monitor and leave it open on the screen that shows your memory usage. Go in game and open/close the map 100 times and look at your memory usage just slowly climbing up. This doesnt happen anymore after this fix. Neither should the crashing related to the map closing specifically. I've tested on 800+ open/closes with no crash and its good enough for me. I can live with those odds.
Compatibility:
Not compatible with mods that ship their own ApseMap.gfx except for Elfi's UI Tweaks who gave me permission to publish a patch between our two ApseMap.gfx files. Credits for the map tweaks that are not my bugfix go to Elfi0044. Load order: Compatibility patch goes AFTER either one of our mods. Doesnt matter.
Crash On Map Close Fix — technical summary
The bug (vanilla ApseMap.gfx)
The world map is a streaming tile engine. GlobalMap. Load and LocalMap. Load pull each map tile in asynchronously via MovieClipLoader.loadClip("img://Libs/UI/Textures/Maps/…dds", tileClip); the engine signals completion by calling back into cry_onStreamed. On close (fc_clear), the teardown paths — GlobalMap. Unload, LocalMap. Unload, and LocalMap. Clear — dispose the tiles with removeMovieClip() only. Crucially, removeMovieClip() tears down the display object but does not cancel a pending img:// load or release the streamed DDS texture, and there is no unloadClip/unloadMovie call anywhere in the file.
That single omission produces two failures, one root cause:
Crash on close. With deferred UI unload (wh_ui_ApseUnloadMode ≥ 1), the map movie is freed after the close. If a tile stream is still in flight, its completion lands on a freed/removed target → native crash. It's a race — random (roughly 1-in-many closes), worse the more aggressively the engine frees (mode 1 = crashiest), and absent at mode 0 only because the synchronous unload cancels streams atomically.
Memory leak. Tiles that finished streaming are never released on close either, so every map open allocates a fresh tile-set on top of ones never reclaimed → monotonic memory growth → eventual out-of-memory crash.
Cancel each tile's stream before removing its clip. Added tileClip.unloadMovie() immediately before every teardown removeMovieClip() in the three sites (a loop over m_TilesA in GlobalMap. Unload, LocalMap. Unload, and LocalMap. Clear). unloadMovie() both cancels a pending img:// load (kills the race) and releases a finished texture (kills the leak). It runs only during map teardown, so normal map use is unaffected.
Decompiled ApseMap.gfx with FFDec, edited
📊 Mod Details
- Game
- Kingdom Come 2 Mods
- Author
- thazer
- Version
- 1
- Downloads
- 176
- Endorsements
- 3
- Category
- User Interface
- Created
- 8/7/2026
- Updated
- 8/8/2026
🔧 How to Install KCD2 Mods
Use Vortex or manual.
📖 Full step-by-step install guide for KCD2 →
Visit the official mod page for specific installation instructions for this mod.
🎮 Need cheat codes or console commands? Check ur gaming wiki for KCD2 commands, item IDs, and more.
Keep browsing — more KCD2 mods await