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
I previously discussed this in detail in the Godot Proposals repository: godotengine#10826
The TL;DR is that StringNames and NodePaths create insidious garbage collection performance spikes in C#, due to allocation of new objects inside implicit casts.
Input.IsActionPressed("action");// Allocated a StringName.GetNode("path/to/node");// Allocated a NodePath.
This is my current workaround:
globalusingstaticRecycleExtensions;usingZiggyCreatures.Caching.Fusion;publicstaticclassRecycleExtensions{privatestaticreadonlyFusionCacheStringNameCache=new(newFusionCacheOptions());privatestaticreadonlyFusionCacheNodePathCache=new(newFusionCacheOptions());/// <summary>/// Converts the string to a StringName, recycling if possible./// </summary>publicstaticStringNameStringName(stringString){returnStringNameCache.GetOrSet(String, _ =>(StringName)String);}/// <summary>/// Converts the string to a NodePath, recycling if possible./// </summary>publicstaticNodePathNodePath(stringString){returnNodePathCache.GetOrSet(String, _ =>(NodePath)String);}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I previously discussed this in detail in the Godot Proposals repository: godotengine#10826
The TL;DR is that StringNames and NodePaths create insidious garbage collection performance spikes in C#, due to allocation of new objects inside implicit casts.
This is my current workaround:
The solution would be one of the following:
Beta Was this translation helpful? Give feedback.
All reactions