In our current project, we use Photon room properties to sync entities. and i noticed some heavy GC Allocs while deep profiling the game and it always ends down to this method.
Have anyone faced this issue before ? or attempted to fix it ? here is the source code of that method.
/// <summary>
/// This removes all key-value pairs that have a null-reference as value.
/// Photon properties are removed by setting their value to null.
/// Changes the original passed IDictionary!
/// </summary>
/// <param name="original">The IDictionary to strip of keys with null-values.</param>
public static void StripKeysWithNullValues(this IDictionary original)
{
object[] keys = new object[original.Count];
original.Keys.CopyTo(keys, 0);
for (int index = 0; index < keys.Length; index++)
{
var key = keys[index];
if (original[key] == null)
{
original.Remove(key);
}
}
}