Memory leak when loading multiple save files in the same session
Issue
RAM usage only increases when loading more than one save game
Steps to Reproduce
1. Start the game and load up a save file. Check RAM usage as a baseline.
2. Once the save file is loaded, load another save file. The RAM usage only increases compared to the baseline and does not decrease.
2. b. (Alternatively) Once the save file is loaded, quit to the main menu. The RAM usage does not decrease compared to the baseline here either. When loading another save file, the RAM usage does increase from the baseline but not decrease.
3. Repeat ad infinitum until the system runs out of RAM memory.
Possible Workaround
Players with a system that has more limited RAM resources, restart the game before loading a different save file. Players that have more RAM resources available do not need to worry about loading a couple of saves consecutively, though mileage may vary.
Comments: 2
-
11 Jan, '22
TechWizardI did a bit more testing and I am able to reproduce it consistently. Interestingly though, if you are loading up a second save and while it is loading furiously click the loading screen forcing the game to freeze up, (become white and Windows 10 complaining the game has become unresponsive) and wait for the game to respond, the RAM usage does decrease significantly to a bit more than baseline levels. This also seems to indicate that Windows is forcibly freeing up memory allocated to the game, which then gets reallocated but less than before because it does not need to load stuff it does not need but remained in memory. Therefore, I believe that the memory leak is related to not freeing up memory that is no longer needed.
-
16 Aug, '22
SapioitI found another way to replicate this:
4. Load a game, play the game for a sufficiently-long time, the game will eventually freeze and crash due to running out of memory.
My experience also indicates that the memory leak is caused by not freeing up memory which is no longer needed.
I should mention that I am using WIndows 7 x64 with 8 GB RAM. In the stable branch, it happens after a 1-3 hours after loading a save. After updating to the experimental mode and installing some mods, it happens after 30-60 minutes after loading a save.
Edit: Related thread: https://timberborn.featureupvote.com/suggestions/265946/memory-leak-in-experimental-mode
Edit2: it just occurred to me that the memory leak is likely caused by the garbage collection, which is lacking (incomplete or missing entirely) for some parts of the code.