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
- Awaitable.NextFrameAsync() fails to resume when invoked multiple times from the playModeStateChanged event
- Text input duplicates in the TextField when textField.isDelayed is set to true and typing with a Japanese keyboard layout
- “AssetDatabase.GetMainAssetTypeAtPath" returns the incorrect type when using a global namespace class with the same name as a Unity type
- Editor silently crashes when switching platforms when Meta XR Core SDK is imported
- Crash on Object::SetCachedScriptingObject when entering the Play Mode immediately after stopping asynchronous operations in the previous Play Mode session
Resolution Note (fix version 2021.2):
Fixed in 2021.2.0a14