Search Issue Tracker
Won't Fix
Votes
0
Found in [Package]
1.1.0-pre.5
Issue ID
1338934
Regression
No
Fair amount of garbage is allocated when using Input System
1. Open the attached project "InputSystemGC2.zip"
2. Open the "SampleScene" Scene
3. Open Profiler (Window > Analysis > Profiler)
4. Enter Play Mode
5. Make sure the Module details panel is in Hierarchy view and the "Live" button is toggled on
6. Hold the left mouse button in the Game view
7. While holding the left mouse button look at the Profiler window
Expected result: No garbage or less garbage gets created
Actual result: Some garbage is created
Reproducible with: 1.0.0 (2019.4.28f1, 2020.3.13f1), 1.1.0-pre.5 (2019.4.28f1, 2020.3.13f1, 2021.1.14f1, 2021.2.0b2, 2022.1.0a1)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Warning 'Unable to find player assmebly' is thrown when building some Project Templates
- ArgumentOutOfRangeException when manipulating the Project Settings search bar
- [Linux] Touch freezes in Player when any mouse button is clicked
- UnityEngine.Rendering.Volume.OnEnable() is called twice before OnDisable() creating multiple copies of the same volume when a volume is enabled right after Domain Reload when entering Play Mode
- Hinge Joint transforms are reset when toggling the "useMotor" property
Resolution Note:
I analyzed the provided deep profile and as highlighted in provided screenshots there is managed dynamic memory allocation happening in frame 74 as clearly stated in this case. Drilling down into the callstack starting from PreUpdate.NewInputUpdate() as root, its possible to see that the dynamic allocation originates from UnityEvent and Mono.JIT as previously elaborated on. However, looking into subsequent frames, e.g. 75, 76, 77 etc GC alloc is zero, i.e. its possible to see that no additional GC Alloc is performed. Stepping forward its visible that any GC Alloc is also either driven by UnityEvent or Mono.JIT. UnityEvents are used for callbacks from the input framework but is outside the implementation of the Input system itself.