Garbage generated by InputDeviceManager
Posted: Fri Jul 04, 2025 6:05 am
Hey,
I just wanted to highlight an issue I noticed recently in InputDeviceManager. I noticed I was getting frequent spiky frames due to GC, and one cause of garbage came from this component, from the DefaultGetKeyDown method. It generates garbage every frame as a result of using string.ToLower. I wonder if case-invariant checking is really necessary there? And if it is, I think it would be better to use something like:
and
to avoid this garbage generation. Not a big deal for me, as I think I actually don't need this component at all (at least I've found no bad side effects yet of removing it), but might be helpful for others as this component is I think included by default. Kind regards,
Andy
I just wanted to highlight an issue I noticed recently in InputDeviceManager. I noticed I was getting frequent spiky frames due to GC, and one cause of garbage came from this component, from the DefaultGetKeyDown method. It generates garbage every frame as a result of using string.ToLower. I wonder if case-invariant checking is really necessary there? And if it is, I think it would be better to use something like:
Code: Select all
s.StartsWith("mouse", StringComparison.InvariantCultureIgnoreCase))
Code: Select all
string.Compare(s, "mouse0", true) == 0
Andy