com.unity.webrtc
com.unity.webrtc copied to clipboard
[BUG]: GetStats Causing Memory Leak
Package version
2.4.0-exp.6
Environment
* OS: Windows 10
* Unity version: 2021.1.13f1
Steps To Reproduce
- Open the Stats sample scene from the provided Samples.
- Modify line 284 of StatsSample.cs to
yield return new WaitForSeconds(0.0f);to speed up the memory leak.
- NOTE: This step only amplifies the leak, we also saw the leak occuring when there is no change to this file.
- Open Task Manager.
- Run the Stats scene and watch the memory steadily go up in Task Manager.
Current Behavior
I first saw this in my own scene in which I wanted to see realtime WebRTC stats in a text box. After some work, we noticed that the memory usage kept going up at every call to the GetStats() method. We confirmed this behaviour first by removing everything in our method but the single call to GetStats, then moving to see if we could replicate in the Stats sample scene.
After about 10 minutes of running the Stats sample with the calls to the GetStats() method happening as fast as possible, we saw that a little over 2000 MB of memory leaked.
Expected Behavior
We expect that there is no memory leak from calling the GetStats method.
Anything else?
We tested a build on Android and Windows with both experiencing a memory leak. Further, the memory is only released when the play session is over.
@AustinMathuw Thanks you for reporting. We will check this issue. memo: WRS-283
Fixed in https://github.com/Unity-Technologies/com.unity.webrtc/pull/816