Don't allocate memory every tick
Checking the number of allocated bytes in think
of an otherwise empty Responder reveals that 2144 bytes get allocated every tick. Eventually it reaches the threshold where garbage collection needs to run, which causes noticeable stutter, especially when media is playing.
Out of those 2144 bytes:
- 1744 bytes are because of InputState allocations (there's some groundwork for getting rid of it in !262 (closed), although as it is right now it makes it 144 bytes worse)
- 192 bytes are from ReactorStats.record_render_time (fixed in !348 (merged))
- 192 bytes are from ReactorStats.record_run_time (fixed in !348 (merged))
- 16 bytes are yet to be identified
About every second additional 16 bytes are being allocated as well, also to be identified.
When running a View (as opposed to a bare Responder), additional 544 bytes get allocated too. BaseView adds another 192 bytes on top (most likely in InputController), so 2880 in total.
Ideally there would be no per-tick allocations to collect caused by the system at all.