Hi,
I’m profiling my game and I found a piece of “code”(?) that triggers 500b in certain occasions. I’m adding a screenshot at the bottom, but at the top of the hierarchy we get Action`1.invoke.void_T(). As far as I know, Action Events (which we use extensively) does not add any garbage other than when registering new listeners, but not when invoking. So is this like some garbage that is being hard to report with because an Action is being used? Or is this some overhead from using the profiler and nothing to worry about.
Unity.ResourceManager.dll!UnityEngine.ResourceManagement.Profiling::ProfilerFrameData`2.set_Item()
Unity.ResourceManager.dll!UnityEngine.ResourceManagement.Profiling::ProfilerRuntime.RefreshChangedReferenceCounts()
Unity.ResourceManager.dll!UnityEngine.ResourceManagement.Profiling::ProfilerRuntime.PushToProfilerStream()
Unity.ResourceManager.dll!UnityEngine.ResourceManagement.Profiling::ProfilerRuntime.InstanceOnOnLateUpdateDelegate()
Unity.ResourceManager.dll!::MonoBehaviourCallbackHooks.LateUpdate()
Thank you!
I changed the title because it seems I found the culprit: LocalizedString()
. It has been quite the witch hunt trying to find the reason I get this allocation, but I was able to narrow it down to this call from Unity.Localization.
I’m just running this simple snippet after I figured what the issue was. Every time I press the number 8 I get two 0.5Kb spikes for the LocalizedString()
. What’s more frustrating was that the profiler is very obscure about this, I imagine is because of the async
nature of the call.
Is this allocation expected and is there anything that we can do about it? I guess I could cache it, but that just overcomplicates this.
if (Input.GetKey(KeyCode.Alpha8))
{
using (InteractingMehod.Auto())
{
InspectorConstantManager.Instance.ContainerPrompts.FullContainer.GetLocalizedString();
}
}
Below you can see the two spikes that are both 0.5Kb, and they only happen after I call GetLocalizedString(). I’m using this as the prompts the player sees which are dynamic base on the interactions and also for the feed which can get a good amount of messages after finding lots of loot which can then stress the game quite a bit.
I’m using 2022-3-LTS. 2022.3.39. Localization 1.5.3.
Does this happen every time or just the first time? We use pooled objects so the first time may allocate but those instances will be reused.
Thanks @karl_jones, this happens everytime I call the snippet
Can you do a capture with deep profiling enabled?
What version of the package are you using?
Not much info in Deep Profiling:
You can see the peaks are everytime I pressed the button to call the snippet. I’m using I’m using 2022-3-LTS. 2022.3.39. Localization 1.5.3.
From the callstack it looks like it’s the addressables profiler code,not localization.
Feel free to file a bug report, maybe we can do something to remove it although it’s nothing to worry about as it won’t happen when the profiler is not running.
2 Likes