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
- Missing script error when clicking “script” link in Cave scene’s Water Sample Description
- [VFX Graph] Set Position Shape Gizmo isn't refreshed after shaper switch
- NullReferenceException is thrown when trying to access volumeStack from the HDCamera class
- Visual artifacts appear when using an Orthographic camera with a Reflection Probe
- Not all animation properties are accessible when a prefab with an avatar model contains a nested copy of itself with a renamed GameObject
Resolution Note (fix version 2021.2):
Fixed in 2021.2.0a14