We are developing a soccer game, and our dedicated server instance is destroyed after each game, as we know in soccer, we have limited game time, and our test shows that we are eating around 100mb of memory tops during the entire match.
Garbage collector fires each time we open up a map (LoadMap) and on this server we have only 1 single map that opens during the game and as the game finishes we destroy the server.
We would love to improve our CPU utilization by opting out GC completely, could you point us how could we do this?
I tried to disable inside the `bool UEngine::LoadMap( FWorldContext& WorldContext, FURL URL, class UPendingNetGame* Pending, FString& Error )` but it looks like the system is checking itself and spits up errors and crashes on LoadMap 
Could you assist please?
Steps to Reproduce
We are developing a soccer game, and our dedicated server instance is destroyed after each game, as we know in soccer, we have limited game time, and our test shows that we are eating around 100mb of memory tops during the entire match.
Garbage collector fires each time we open up a map (LoadMap) and on this server we have only 1 single map that opens during the game and as the game finishes we destroy the server.
We would love to improve our CPU utilization by opting out GC completely, could you point us how could we do this?
I tried to disable inside the `bool UEngine::LoadMap( FWorldContext& WorldContext, FURL URL, class UPendingNetGame* Pending, FString& Error )` but it looks like the system is checking itself and spits up errors and crashes on LoadMap 
Could you assist please?
Hi there,
While I understand you are looking to disable garbage collection entirely on your server, I’d strongly recommend against it. Unreal’s runtime and object lifecycle management are tightly coupled with the garbage collector, and many engine systems assume that GC will run regularly. Disabling it outright (especially by overwriting internal engine functions like in LoadMap) could easily lead to engine instability.
Instead, I’d suggest focusing on optimising your GC behaviour rather than removing it. Some options to consider:
- Increase the GC interval: You can lengthen the time between GC runs using Time Between Purging Pending Kill Objects, or disable incremental destruction via Incremental BeginDestroy Enabled if you prefer to batch cleanup manually.
- Use CollectGarbage() manually: If you know exactly when it’s safe and performant to clean up (potentially after a match ends), you could trigger a manual GC pass and avoid random GC spikes during gameplay.
Here is some additional documentation on garbage collection that you may find valuable:
Regards,
Thomas
Hello.
In our project, we use dedicated‐server forks that don’t accumulate many objects over their lifetime; after 3–5 minutes of gameplay the fork is destroyed and a new one is created for the next game session. We don’t see a strong need to force GC during map loading, especially since it happens immediately after the fork is created and no garbage has yet built up. We added a console variable that causes an early return from UEngine::ConditionalCollectGarbage() if the variable is set to true, thereby avoiding unnecessary GC calls. But one problem remains — level loading.
Of course GC can be optimized, but the spikes it generates in single‐threaded mode are quite significant, and with an average frame time of 5 ms, GC can consume 10–20 ms of CPU time. Unfortunately, we don’t see any benefit from using GC on forks.
Regards,
Edward
[Image Removed]This is AMD EPYC 7B13.
Hi there,
Thank you for the additional context.
If you wanted to disable GC after a level is requested to unload, you could disable the following CVar s.ForceGCAfterLevelStreamedOut as outlined in this documentation here. This will remove the forced garbage collection as a level is unloaded.
Otherwise, incremental garbage collection may be of interest to spread the work over multiple frames.
If neither of these options are appropriate for your use case, and you are looking to make an engine modification to manually disable GC on LoadMap, I can look to elevate this to a subjuct matter expert who can point you in the right direction.
Thanks,
Thomas