Trim memory usage of IReadOnlyPackage implementations.

These implementations are often backed by a Dictionary, and tend to live a long time after being loaded. Ensure TrimExcess is called on the backing dictionaries to reduce the long term memory usage. In some cases, we can also preallocate the dictionary size for efficiency.
This commit is contained in:
RoosterDragon
2024-04-01 14:29:37 +01:00
committed by Gustas
parent ed5c7bb836
commit a4bb58007f
6 changed files with 23 additions and 11 deletions

View File

@@ -54,6 +54,8 @@ namespace OpenRA.Mods.D2k.PackageLoaders
var length = s.ReadUInt32();
index.Add(name, new Entry(offset, length));
}
index.TrimExcess();
}
catch
{