Page 1 of 1

Garbage generated by InputDeviceManager

Posted: Fri Jul 04, 2025 6:05 am
by effalumper
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:

Code: Select all

s.StartsWith("mouse", StringComparison.InvariantCultureIgnoreCase))
and

Code: Select all

string.Compare(s, "mouse0", true) == 0
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

Re: Garbage generated by InputDeviceManager

Posted: Fri Jul 04, 2025 8:35 am
by Tony Li
Hi,

Oops, didn't realize that was still in there. I'll make sure that's fixed in the next update.