com.unity.webrtc icon indicating copy to clipboard operation
com.unity.webrtc copied to clipboard

[BUG]: GetStats Causing Memory Leak

Open AustinMathuw opened this issue 3 years ago • 1 comments

Package version

2.4.0-exp.6

Environment

* OS: Windows 10
* Unity version: 2021.1.13f1

Steps To Reproduce

  1. Open the Stats sample scene from the provided Samples.
  2. 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.
  1. Open Task Manager.
  2. 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 avatar Apr 05 '22 15:04 AustinMathuw

@AustinMathuw Thanks you for reporting. We will check this issue. memo: WRS-283

kannan-xiao4 avatar Apr 12 '22 02:04 kannan-xiao4

Fixed in https://github.com/Unity-Technologies/com.unity.webrtc/pull/816

kannan-xiao4 avatar Oct 04 '22 02:10 kannan-xiao4