Project

General

Profile

Bug #25218

1.2.2 to 1.9.1 Memory leak is proportional to the size of the game save

Added by Anth12 almost 4 years ago. Updated about 3 years ago.

Status:
Confirmed
Severity:
Low
Assignee:
-
Category:
Application
Target version:
-
Start date:
04/26/2020
% Done:

10%

Version:
Platform:
Windows
Expansion:
Core Game
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

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

1.1.3 Large Save Test.zip (2.29 MB) 1.1.3 Large Save Test.zip Anth12, 04/26/2020 12:27 PM
1.2.2 Large Save Test.zip (2.41 MB) 1.2.2 Large Save Test.zip Anth12, 04/26/2020 12:27 PM
1.9.1 Large Save Test.zip (2.58 MB) 1.9.1 Large Save Test.zip Anth12, 04/26/2020 12:27 PM
1.9.1 DLCs Large Save Test.zip (3.21 MB) 1.9.1 DLCs Large Save Test.zip Anth12, 04/26/2020 12:27 PM
18000 113 122 191 191DLCs.png (17 KB) 18000 113 122 191 191DLCs.png Anth12, 04/27/2020 07:15 AM
191DLCs 0 9000 18000 Parts.png (19.2 KB) 191DLCs 0 9000 18000 Parts.png Anth12, 04/27/2020 07:15 AM
Testing Results Graphs Clarified.xlsx (26.6 KB) Testing Results Graphs Clarified.xlsx Anth12, 04/27/2020 07:22 AM
52231
52232

History

#1 Updated by Anth12 almost 4 years ago

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 almost 4 years ago

  • File Testing Results.xlsx added

#3 Updated by Anth12 almost 4 years ago

  • File deleted (Testing Results.xlsx)

#4 Updated by Anth12 almost 4 years ago

  • File deleted (Testing Results.xlsx)

#5 Updated by Anth12 almost 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 almost 4 years ago

  • File deleted (18000 113 122 191 191DLCs.png)

#7 Updated by Anth12 almost 4 years ago

  • File deleted (191DLCs 0 9000 18000 Parts.png)

#8 Updated by Anth12 almost 4 years ago

52231
52232

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 almost 4 years ago

  • File deleted (Testing Results.xlsx)

#11 Updated by Anonymous over 3 years ago

  • Status changed from New to Confirmed
  • % Done changed from 0 to 10

#12 Updated by Anth12 over 3 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:

  1. First time its loaded from the main menu
  2. Everytime going from a loaded scene to the KSC screen
  3. Everytime going from the KSC screen to the SPH/VAB
  4. Everytime that a craft is launched from the SPH/VAB
  5. Everytime that a craft is loaded from the tracking station
  6. Everytime going from a loaded scene to the tracking station
  7. 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.

Also available in: Atom PDF