Photon Realtime, StripKeysWithNullValues cause heavy GC Alloc

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.

enter image description here

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);                 }             }         } 

How to optimzie GC alloc in unity

I have to load/unload models from a specific url based on player position. For this reason I am checking player position from model and then load/unload related piece of model in a Update event which runs on every frame.

Here is the update, that validating some checks before loading/unloading. I added this check for optimization purposes as the main loading/unloading loop is heavy:

 private void Update()     {         //If this feature is disable don't load/unload         if (enableThisFeature == false) return;          //if player is moving, dont load//unload         if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)         {             //do nothing when player is moving             return;         }          DeactivateDistantTiles();     } 

After this I am checking player postion and calling model load/unload:

private void DeactivateDistantTiles()     {         playerPosition = transform.position;         playerPosition = cameraController.currentActiveCam.transform.position; //transform.position;          checkPlayerPositionChangeing = playerPosition.z != playerLastPos.z || playerPosition.x != playerLastPos.x;          if (checkPlayerPositionChangeing)         {             ABLoadUnloadLoopCall();         }           playerLastPos = cameraController.currentActiveCam.transform.position;      }     Vector3 tilePosition;     float xDistance;     float zDistance;     public void ABLoadUnloadLoopCall()     {            //old             //foreach (SingleABLoader tile in tiles)             //{             //    Debug.Log("ABLoadUnloadLoopCall 123");             //    Vector3 tilePosition = tile.gameObject.transform.position + (tileSize / 2f);              //    float xDistance = Mathf.Abs(tilePosition.x - playerPosition.x);             //    float zDistance = Mathf.Abs(tilePosition.z - playerPosition.z);              //    if (xDistance + zDistance > maxDistance)             //    {             //        /*If you don't want to destroy the object on unload then use below line otherwise use DestroyBundleObject with true pararmeter */             //        //tile.DestroyBundleObject();             //        tile.DestroyBundleObject(true);             //    }             //    else             //    {             //        tile.StartDownloadingAB();             //    }              //}             //new             for(int i = 0; i < tiles.Length; i++)             {                  tilePosition = tiles[i].gameObject.transform.position + (tileSize / 2f);                   xDistance = Mathf.Abs(tilePosition.x - playerPosition.x);                  zDistance = Mathf.Abs(tilePosition.z - playerPosition.z);                  if (xDistance + zDistance > maxDistance)                 {                      /*If you don't want to destroy the object on unload then use below line otherwise use DestroyBundleObject with true pararmeter */                     //tiles[i].DestroyBundleObject();                     tiles[i].DestroyBundleObject(true);                  }                 else                 {                     tiles[i].StartDownloadingAB();                 }              }       } 

I found that ABLoadUnloadLoopCall making GC allocation in KBs which is very high. So is there any way available that my above code optimize and make less allocation. My initial research suggest to use For loop instead foreach therefore in ABLoadUnloadLoopCall i am using for loop instead foreach but still my game lag/freeze for some minutes after loading the model.

Help on “alloc magic is broken” – dual boot

A couple of months ago I installed Ubuntu along Windows using dual boot. Everything was working fine, I was able to boot on either OS, till yesterday, when I restarted the pc to boot into Windows, and there appeared an unusual black screen with a few points in the middle – I guess indicating that something was being loaded – that was taking so long to end that I powered off the pc. Next times I’ve tried to boot into Windows, the following error has been popping up:

“alloc magic is broken at 0x6fea7f20: 0 Aborted. Press any key to exit.”

So I go back to the boot window and select Ubuntu, and it works normally. I’ve been searching for a solution in order to be able to boot in both OS, but despite there are many reports on this problem – and proposed solutions that only work in some specific cases – most of the times it’s Ubuntu that users cannot access, and the code after “broken at ..” changes every time they try. In my case, that code is always the same. My OS are Windows 10 and Ubuntu 18.04.2 LTS. Please excuse me if any important info is missing, I’m pretty new to the world of Linux. I’ll appreciate any word of advice.

Thanks a lot!