DeviceController audio memory leak
See original GitHub issueWhat happened and what did you expect to happen?
I was profiling a simple React component that only imports the chime JS sdk. It simply creates a new DefaultDeviceController when mounted, and calls the .destroy()
method on unmount.
It seems that AudioBufferSourceNode
persists and a new one is created every time the component is mounted.
This was discovered using heap snapshots in Chrome.
Heap snapshot of initially unmounted component that is mounted and unmounted, repeated twice (Unmounted, Mounted, Unmounted, Mounted, Unmounted):
Have you reviewed our existing documentation?
Reproduction steps
- Create a new
DefaultDeviceController
- Call
.destroy()
on the created instance - Create a new instance of
DefaultDeviceController
again - Memory leak is observed with an additional
AudioBufferSourceNode
Amazon Chime SDK for JavaScript version
2.17.0
What browsers are you seeing the problem on?
Chrome
Browser version
94.0.4606.71
Meeting and Attendee ID Information.
No response
Browser console logs
N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Audio memory leak - Microsoft Community
I have windows 10 and about a couple weeks ago out of the blue, my audio is using an absurd amount of ram...
Read more >DeviceController | amazon-chime-sdk-js
... you should perform some cleanup steps in order to avoid memory leaks: Call DeviceController.destroy to stop all active audio and video inputs....
Read more >web audio memory leak #5224 - photonstorm/phaser - GitHub
I've checked and see massive memory leak. I made small test as a demo with 1mb audio file to show the problem quickly...
Read more >Xcode Audio Memory Leak? - Stack Overflow
I'm working on a soundboard app, and when I analyze my app, it always detects memory leaks. It works fine on the iOS...
Read more >DeviceController audio memory leak - Aws/Amazon-Chime ...
DeviceController audio memory leak ... This issue has been created since 2021-10-08. What happened and what did you expect to happen? I was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am running into the same issue. I am not using using the React components but rather using the SDK in an Angular app. What I discovered when trying to figure out why the memory in our app was increasing after every meeting is that the “AudioBufferSourceNode” objects were being created during the teardown of the meeting. Initially followed the convention used in the examples for tearing down by calling
MeetingSession.audioVideo.chooseXXXDevice(null)
. ThechooseAudioInputDevice(null)
is creating a the empty audio device. Next tried callingMeetingSession.destroy()
, which is not documented anywhere, instead of callingchooseAudioInputDevice(null)
. This resulted in the same behavior because it is doing the same thing.Overall there needs to be a short circuit when calling
chooseAudioInputDevice(null)
duringdestroy
so it does not create new resources that are never cleaned up. The following reference is what is creating the empty device during destroy.https://github.com/aws/amazon-chime-sdk-js/blob/17a5fc7163cf020deeaa90ff45ee414188504862/src/devicecontroller/DefaultDeviceController.ts#L1465
@emopti-jrufer Hi, thanks for providing such a detailed observation. We are working on a fix now.