Search Issue Tracker
Fixed in 2021.2.X
Votes
0
Found in
2018.4
2019.4
2020.2
2020.2.0f1
2021.1
2021.2
Issue ID
1303095
Regression
No
Memory of non persistent event listeners isn't cleared when calling UnityEventBase.RemoveAllListeners
How to reproduce:
1. Open the attached "1303095 repro" project
2. Open the "SampleScene" Scene from the Assets folder
3. Open the Profiler window from Window > Analysis > Profiler
4. Open the Memory module of the Profiler
5. Enter Play Mode
Expected results: the GC Used Memory is around 25MB
Actual results: the GC Used Memory is around 515MB
Reproducible with: 2018.4.30f1, 2019.4.17f1, 2020.2.1f1, 2021.1.0b2, 2021.2.0a1
Notes:
-The issue reproduces with both Mono and IL2CPP Scripting Backends and with both .NET Standard 2.0 and .NET 4.x API Compatibility Levels
-If the "Should Clear" checkbox is checked on the "Sample Script", the memory will be released after invoking the event with 0 listeners
-The issue can also be observed in the Console window with the Debug messages printing the results of GC.GetTotalMemory()
-The issue is present in the Editor and a built project
- GC.Collect() doesn't free up any memory even after removing all listeners
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
- The Camera first person mode in Cameras overlay is greyed out and not clickable when the Editor is restarted with the Game View focused
- Scene View doesn't select the Canvas when it's clicked with the View Tool
- Transform fields are impossible to edit when Inspector window is resized
- Actions in UI Builder Preview mode are not fully reset after exiting the Preview mode
- Transform field values are no longer visible when Inspector window is resized
Resolution Note (fix version 2021.2):
Fixed in 2021.2.0a14