From 2481bddf58c0093edf3c978555c8c1f232b10db4 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Mon, 1 Apr 2024 14:38:41 +0100 Subject: [PATCH] Trim memory usage of FileSystem. When LoadFromManifest is called, trim the various backing collections. These backing collections tend to live a long time without further modifications. --- OpenRA.Game/FileSystem/FileSystem.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenRA.Game/FileSystem/FileSystem.cs b/OpenRA.Game/FileSystem/FileSystem.cs index f6518ee173..f1e8a7a6f0 100644 --- a/OpenRA.Game/FileSystem/FileSystem.cs +++ b/OpenRA.Game/FileSystem/FileSystem.cs @@ -186,6 +186,12 @@ namespace OpenRA.FileSystem UnmountAll(); foreach (var kv in manifest.Packages) Mount(kv.Key, kv.Value); + + mountedPackages.TrimExcess(); + explicitMounts.TrimExcess(); + modPackages.TrimExcess(); + foreach (var packages in fileIndex.Values) + packages.TrimExcess(); } Stream GetFromCache(string filename)