RonenNess / GeonBit.UI

UI system for MonoGame projects.
MIT License
467 stars 63 forks source link

Memory Leak in DefaultInputProvider.Update #99

Closed JRileyH closed 2 years ago

JRileyH commented 5 years ago

Using Xamarin Profiler I found millions of the Keys class being instantiated in DefaultInputProvider.Update when you iterate over System.Enum.GetValues(typeof(Keys)). Several Megabytes in a few seconds and growing.

screen shot 2018-12-22 at 9 45 51 am

(this was taken after about 10 seconds)

Adding private class variable Keys[] _allKeys = (Keys[])System.Enum.GetValues(typeof(Keys)); and iterating over that reduces memory usage to a few kB and remains perfectly steady.

screen shot 2018-12-22 at 9 48 14 am

(this was taken after about 2 minutes with this change)

I have a local branch with this change and would be happy to make a PR with contributor permission.

RonenNess commented 2 years ago

Fixed long time ago, but forgot to update the issue. Thanks for the info :)