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

Scripting

-

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

  1. Response avatar

    Resolution Note (fix version 2021.2):

    Fixed in 2021.2.0a14

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.