You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
foreach(CanonicalTileIdidincover){vartile=newT();Tile.Parametersparam;param.Id=id;param.MapId=this.mapId;param.Fs=this.fs;// this is a closure!tile.Initialize(param,()=>{this.NotifyNext(tile);});this.tiles.Add(tile);this.NotifyNext(tile);}
Currently, inspection of code generated by IL2CPP reveals that the simple declaration and assignment of a variable of type System.Function allocates a new object. This is true whether the variable is explicit (declared in a method/class) or implicit (declared as an argument to another method).
As such, any use of anonymous methods under the IL2CPP scripting backend allocates managed memory. This is not the case under the Mono scripting backend.
Furthermore, IL2CPP displays dramatically different levels of managed memory allocation depending on the way in which a method argument is declared. Closures, as expected, allocate the most memory per call.
Unintuitively, predefined methods allocate nearly as much memory as closures when passed as arguments under the IL2CPP scripting backend. Anonymous methods generate the least amount of transient garbage on the heap, by one or more orders of magnitude.
This would require us to remove Action as method arguments. Prefer C# events?
From
Map.cs:As noted from the Unity documentation:
This would require us to remove
Actionas method arguments. Prefer C# events?/cc @brnkhy @isiyu @BergWerkGIS