Bug #25218
1.2.2 to 1.9.1 Memory leak is proportional to the size of the game save
10%
Description
This issue started in 1.2 and remains in KSP in the latest release.
Testing
Attached excel file shows a series of actions I took and at which points I recorded the memory usage
of KSP at that time.
Results:
First Graph from the excel file shows a similar curve/line that started in 1.2 and is still in 1.9 for the
same save that has 18000 parts (files vary according to version but it’s the same save upgraded)
Second Graph shows that a 9000 part save still has the memory issue but isn’t increasing at the same
rate.
Conclusion
I don’t think this bug is about scene changes,
I think the memory is leaking when the game is being loaded or saved in any way.
That’s where I recommend looking for a solution to this problem
History
#1 Updated by Anth12 over 4 years ago
- File 1.1.3 Large Save Test.zip 1.1.3 Large Save Test.zip added
- File 1.2.2 Large Save Test.zip 1.2.2 Large Save Test.zip added
- File 1.9.1 Large Save Test.zip 1.9.1 Large Save Test.zip added
- File 1.9.1 DLCs Large Save Test.zip 1.9.1 DLCs Large Save Test.zip added
Attached are all the Save folders used.
1.1.3 is the original (to show the issue didnt start until 1.2.2)
1.2.2 is fully upgraded from 1.1.3
1.9.1 is fully upgraded from 1.1.3
1.9.1 DLCs (MH+BG) is fully upgraded from 1.1.3
1.9.1 DLCs includes 0 object save, 9000 object save, 18000 object save.
All the others just have the 0 and the 18000
#2 Updated by Anth12 over 4 years ago
- File Testing Results.xlsx added
#3 Updated by Anth12 over 4 years ago
- File deleted (
Testing Results.xlsx)
#4 Updated by Anth12 over 4 years ago
- File deleted (
Testing Results.xlsx)
#5 Updated by Anth12 over 4 years ago
- File Testing Results.xlsx added
Oops needed to remove personal information and reposition where the excel opens to show the tasks done on the left
#6 Updated by Anth12 over 4 years ago
- File deleted (
18000 113 122 191 191DLCs.png)
#7 Updated by Anth12 over 4 years ago
- File deleted (
191DLCs 0 9000 18000 Parts.png)
#8 Updated by Anth12 over 4 years ago
- File 18000 113 122 191 191DLCs.png 18000 113 122 191 191DLCs.png added
- File 191DLCs 0 9000 18000 Parts.png 191DLCs 0 9000 18000 Parts.png added
People on the KSP forums and the reddit were confused by my graphs. sorry about that.
X axis = 55 steps/milestones taken that are mentioned in the excel file. Like SPACECENTER. VAB. Loading Munlander1. Launch. Orbit. Mun Landing. SPACECENTER. SPH. Load Rover1
Y axis = ram usage of KSP copied from the task manager.
#9 Updated by Anth12 over 4 years ago
- File deleted (
Testing Results.xlsx)
#10 Updated by Anth12 over 4 years ago
#11 Updated by Anonymous about 4 years ago
- Status changed from New to Confirmed
- % Done changed from 0 to 10
#12 Updated by Anth12 about 4 years ago
Thanks for the confirmation. Heres more information for consideration.
Subnautica vs Kerbal Space Program For memory issues (Both use Unity):
Subnautica:
Subnautica game saves are generally loaded once per game session into memory.
Kerbal Space Program:
KSP seems to be reloading the game in its entirety many many times into memory from the persistent file in one game session,
Heres a few times I think this is happening:
- First time its loaded from the main menu
- Everytime going from a loaded scene to the KSC screen
- Everytime going from the KSC screen to the SPH/VAB
- Everytime that a craft is launched from the SPH/VAB
- Everytime that a craft is loaded from the tracking station
- Everytime going from a loaded scene to the tracking station
- Everytime going to the KSC Screen
Conclusion:
Subnautica loads the game save once
KSP loads the game save many times.
I 'simulated' Subnautica loading a game save continually for over an hour.
It does appear to have a memory leak if I do that, but a normal gamer would never do that in Subnautica
So yes...its a Unity Problem, sort of.
Suggestions:
Disclaimer: I have no idea of the state of KSP's code or if this is even possible
Load the persistent file once into memory and manipulate it there.
When launching a craft from the SPH/VAB insert it right into the existing universe which is in memory, no need to reload it.
Make the only times that the game is loaded is when the player loads a quick save.
This should reduce the memory leak considerably.