Search Issue Tracker
GUIUtility.BeginGUI() causes memory allocations every time when a GameObject with OnGUI() is instantiated
How to reproduce:
1. Open attached project "case_1380320.zip"
2. Enter Scene "SampleScene" (Assets > Scenes)
3. Make sure the Profiler window is docked in the Editor (View > Analysis > Profiler)
4. Enter "GUIUtility.BeginGUI()" into a search bar inside of the Profiler window
5. Enter Play Mode
6. Select any frame in the Profiler window
7. In the Profiler window's Overview area observe the value in "GUIUtility.BeginGUI()", "GC Alloc" column
8. In the Hierarchy window copy and paste GameObject "GameObject"
9. In the Profiler window clear the frames by pressing the "Clear" button and unpause Play Mode
10. Select any Frame in the Profiler
11. In the Profiler window's Overview area observe "GUIUtility.BeginGUI()" GC Alloc column
Expected result: The value under the "GC Alloc" does not increase
Actual result: The value under the "GC Alloc" column increases by 0.3-0.4 KB
Reproducible with: 2019.4.0f1, 2019.4.33f1, 2020.3.23f1, 2021.2.4f1, 2022.1.0a16
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [UI] Color picker tool is stuck in the pixel sampling stage
- Unity 2019.4 opens the manual and scripting reference for 2020.3
- 'View documentation' doesn't open an offline documentation when the package is added from a local disk
- Public variable's value is unable to be changed when it's above a CustomPropertyDrawer field
- Description of the Surface Effector 2D "Use Contact Force" option contains a typo