diff --git a/Robust.Client/GameController/GameController.cs b/Robust.Client/GameController/GameController.cs index 20ec6bd67..5e17d9313 100644 --- a/Robust.Client/GameController/GameController.cs +++ b/Robust.Client/GameController/GameController.cs @@ -160,8 +160,11 @@ namespace Robust.Client _authManager.LoadFromEnv(); - GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; - GC.Collect(); + if (_configurationManager.GetCVar(CVars.SysGCCollectStart)) + { + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(); + } // Setup main loop if (_mainLoop == null) diff --git a/Robust.Server/BaseServer.cs b/Robust.Server/BaseServer.cs index 145914933..6269c8161 100644 --- a/Robust.Server/BaseServer.cs +++ b/Robust.Server/BaseServer.cs @@ -377,7 +377,10 @@ namespace Robust.Server WindowsTickPeriod.TimeBeginPeriod((uint) _config.GetCVar(CVars.SysWinTickPeriod)); } - GC.Collect(); + if (_config.GetCVar(CVars.SysGCCollectStart)) + { + GC.Collect(); + } ProgramShared.RunExecCommands(_consoleHost, _commandLineArgs?.ExecCommands); diff --git a/Robust.Shared/CVars.cs b/Robust.Shared/CVars.cs index 195401311..a42dca4e4 100644 --- a/Robust.Shared/CVars.cs +++ b/Robust.Shared/CVars.cs @@ -317,6 +317,12 @@ namespace Robust.Shared public static readonly CVarDef SysGameThreadPriority = CVarDef.Create("sys.game_thread_priority", (int) ThreadPriority.AboveNormal); + /// + /// Whether to run a operation after the engine is finished initializing. + /// + public static readonly CVarDef SysGCCollectStart = + CVarDef.Create("sys.gc_collect_start", true); + /* * METRICS */ diff --git a/Robust.UnitTesting/RobustIntegrationTest.cs b/Robust.UnitTesting/RobustIntegrationTest.cs index 5f0e87c6d..fa47c5137 100644 --- a/Robust.UnitTesting/RobustIntegrationTest.cs +++ b/Robust.UnitTesting/RobustIntegrationTest.cs @@ -650,6 +650,7 @@ namespace Robust.UnitTesting { ("log.runtimelog", "false"), (CVars.SysWinTickPeriod.Name, "-1"), + (CVars.SysGCCollectStart.Name, "false"), (RTCVars.FailureLogLevel.Name, (Options?.FailureLogLevel ?? RTCVars.FailureLogLevel.DefaultValue).ToString()) }); @@ -817,6 +818,8 @@ namespace Robust.UnitTesting // Avoid preloading textures. (CVars.ResTexturePreloadingEnabled.Name, "false"), + (CVars.SysGCCollectStart.Name, "false"), + (RTCVars.FailureLogLevel.Name, (Options?.FailureLogLevel ?? RTCVars.FailureLogLevel.DefaultValue).ToString()) });